Indent and unsused imports

This commit is contained in:
anthonyraymond 2017-07-08 18:24:53 +02:00
parent 5607766302
commit 94e7436434
33 changed files with 28 additions and 64 deletions

View file

@ -1,11 +1,6 @@
package org.araymond.joal.core.events.announce;
import com.google.common.base.Preconditions;
import org.araymond.joal.core.ttorent.client.announce.AnnounceResult;
import org.araymond.joal.core.ttorent.client.announce.Announcer;
import org.araymond.joal.core.ttorent.client.bandwidth.TorrentWithStats;
import java.util.Collection;
/**
* Created by raymo on 22/05/2017.

View file

@ -1,13 +1,8 @@
package org.araymond.joal.core.events.announce;
import com.google.common.base.Preconditions;
import com.turn.ttorrent.common.protocol.TrackerMessage.AnnounceRequestMessage.RequestEvent;
import org.apache.commons.lang3.StringUtils;
import org.araymond.joal.core.ttorent.client.announce.AnnounceResult;
import org.araymond.joal.core.ttorent.client.announce.Announcer;
import org.araymond.joal.core.ttorent.client.bandwidth.TorrentWithStats;
import java.util.Collection;
/**
* Created by raymo on 22/05/2017.

View file

@ -1,8 +1,6 @@
package org.araymond.joal.core.events.announce;
import com.google.common.base.Preconditions;
import org.araymond.joal.core.ttorent.client.announce.Announcer;
import org.araymond.joal.core.ttorent.client.bandwidth.TorrentWithStats;
/**
* Created by raymo on 22/05/2017.

View file

@ -1,8 +1,6 @@
package org.araymond.joal.core.events.announce;
import com.google.common.base.Preconditions;
import org.araymond.joal.core.ttorent.client.announce.Announcer;
import org.araymond.joal.core.ttorent.client.bandwidth.TorrentWithStats;
/**
* Created by raymo on 22/05/2017.

View file

@ -3,7 +3,6 @@ package org.araymond.joal.core.events.announce;
import com.google.common.base.Preconditions;
import com.turn.ttorrent.common.protocol.TrackerMessage.AnnounceRequestMessage.RequestEvent;
import org.araymond.joal.core.ttorent.client.announce.Announcer;
import org.araymond.joal.core.ttorent.client.bandwidth.TorrentWithStats;
/**
* Created by raymo on 22/05/2017.

View file

@ -164,7 +164,7 @@ public class Client implements AnnouncerEventListener, TorrentFileChangeAware {
publisher.publishEvent(new AnnouncerHasStoppedEvent(announcer));
if (this.currentState!= ClientState.STOPPING && this.currentState != ClientState.STOPPED) {
if (this.currentState != ClientState.STOPPING && this.currentState != ClientState.STOPPED) {
try {
addSeedingTorrent();
} catch (final NoMoreTorrentsFileAvailableException e) {

View file

@ -17,7 +17,7 @@ public interface AnnounceResponseListener extends EventListener {
* Handle the discovery of new peers.
*
* @param peers The list of peers discovered (from the announce response or
* any other means like DHT/PEX, etc.).
* any other means like DHT/PEX, etc.).
*/
void handleDiscoveredPeers(final TorrentWithStats torrent, final List<Peer> peers);
}

View file

@ -1,7 +1,6 @@
package org.araymond.joal.core.ttorent.client.announce;
import com.google.common.base.Preconditions;
import org.araymond.joal.core.ttorent.client.bandwidth.TorrentWithStats;
import java.time.LocalDateTime;

View file

@ -20,7 +20,8 @@ import java.net.UnknownServiceException;
import java.util.*;
import static com.turn.ttorrent.common.protocol.TrackerMessage.AnnounceRequestMessage;
import static org.araymond.joal.core.ttorent.client.announce.AnnounceResult.*;
import static org.araymond.joal.core.ttorent.client.announce.AnnounceResult.ErrorAnnounceResult;
import static org.araymond.joal.core.ttorent.client.announce.AnnounceResult.SuccessAnnounceResult;
/**
* Created by raymo on 23/01/2017.

View file

@ -78,8 +78,8 @@ public abstract class TrackerClient {
* with the decoded payload.
* </p>
*
* @param event The announce event type (can be AnnounceEvent.NONE for
* periodic updates).
* @param event The announce event type (can be AnnounceEvent.NONE for
* periodic updates).
*/
public final void announce(final AnnounceRequestMessage.RequestEvent event) throws AnnounceException {
logger.debug("Announcing {} to tracker with {}U/{}D/{}L bytes...",
@ -125,7 +125,7 @@ public abstract class TrackerClient {
* listeners.
* </p>
*
* @param message The incoming {@link TrackerMessage}.
* @param message The incoming {@link TrackerMessage}.
*/
protected void handleTrackerAnnounceResponse(final TrackerMessage message) throws AnnounceException {
if (message instanceof ErrorMessage) {

View file

@ -129,7 +129,7 @@ public class BandwidthDispatcher implements AnnouncerEventListener, Runnable {
lock.readLock().lock();
final int torrentCount = this.torrents.size();
for (final TorrentWithStats torrent: this.torrents) {
for (final TorrentWithStats torrent : this.torrents) {
final long uploadRateInBytesForTorrent = torrent.getCurrentRandomSpeedInBytes() / torrentCount;
torrent.addUploaded(uploadRateInBytesForTorrent * updateInterval / 1000);

View file

@ -13,7 +13,7 @@ public class JacksonConfig {
@Bean
public Jackson2ObjectMapperBuilder objectMapperBuilder() {
return new Jackson2ObjectMapperBuilder()
return new Jackson2ObjectMapperBuilder()
.featuresToDisable(
SerializationFeature.WRITE_DATES_AS_TIMESTAMPS
)

View file

@ -35,6 +35,7 @@ public enum StompMessageTypes {
static StompMessageTypes typeFor(final MessagePayload payload) {
return typeFor(payload.getClass());
}
static StompMessageTypes typeFor(final Class<? extends MessagePayload> clazz) {
final StompMessageTypes type = classToType.get(clazz);
if (type == null) {

View file

@ -3,8 +3,6 @@ package org.araymond.joal.web.messages.outgoing.impl.announce;
import com.google.common.base.Preconditions;
import org.araymond.joal.core.events.announce.AnnouncerEvent;
import org.araymond.joal.core.ttorent.client.announce.AnnounceResult;
import org.araymond.joal.core.ttorent.client.announce.Announcer;
import org.araymond.joal.core.ttorent.client.bandwidth.TorrentWithStats;
import org.araymond.joal.web.messages.outgoing.MessagePayload;
import java.util.Collection;

View file

@ -1,10 +1,6 @@
package org.araymond.joal.web.messages.outgoing.impl.announce;
import org.araymond.joal.core.events.announce.AnnouncerHasAnnouncedEvent;
import org.araymond.joal.core.ttorent.client.announce.AnnounceResult;
import org.araymond.joal.core.ttorent.client.bandwidth.TorrentWithStats;
import java.util.Collection;
/**
* Created by raymo on 25/06/2017.

View file

@ -1,12 +1,6 @@
package org.araymond.joal.web.messages.outgoing.impl.announce;
import com.google.common.base.Preconditions;
import org.apache.commons.lang3.StringUtils;
import org.araymond.joal.core.events.announce.AnnouncerHasFailedToAnnounceEvent;
import org.araymond.joal.core.ttorent.client.announce.AnnounceResult;
import org.araymond.joal.core.ttorent.client.bandwidth.TorrentWithStats;
import java.util.Collection;
/**
* Created by raymo on 25/06/2017.

View file

@ -1,7 +1,6 @@
package org.araymond.joal.web.messages.outgoing.impl.announce;
import org.araymond.joal.core.events.announce.AnnouncerHasStartedEvent;
import org.araymond.joal.core.ttorent.client.bandwidth.TorrentWithStats;
/**
* Created by raymo on 25/06/2017.

View file

@ -1,7 +1,6 @@
package org.araymond.joal.web.messages.outgoing.impl.announce;
import org.araymond.joal.core.events.announce.AnnouncerHasStoppedEvent;
import org.araymond.joal.core.ttorent.client.bandwidth.TorrentWithStats;
/**
* Created by raymo on 25/06/2017.

View file

@ -3,8 +3,6 @@ package org.araymond.joal.web.resources;
import org.araymond.joal.web.messages.outgoing.StompMessage;
import org.araymond.joal.web.services.JoalMessageSendingTemplate;
import org.springframework.http.MediaType;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

View file

@ -67,6 +67,7 @@ public class JoalMessageSendingTemplate {
case ANNOUNCER_HAS_STOPPED: {
final String id = ((AnnouncePayload) stompMessage.getPayload()).getId();
replayablePayloads.removeIf(message -> {
//noinspection SimplifiableIfStatement
if (!AnnouncePayload.class.isAssignableFrom(message.getPayload().getClass())) {
return false;
}
@ -77,6 +78,7 @@ public class JoalMessageSendingTemplate {
case ANNOUNCER_WILL_ANNOUNCE: {
final String id = ((AnnouncePayload) stompMessage.getPayload()).getId();
replayablePayloads.removeIf(message -> {
//noinspection SimplifiableIfStatement
if (!AnnouncePayload.class.isAssignableFrom(message.getPayload().getClass())) {
return false;
}
@ -89,6 +91,7 @@ public class JoalMessageSendingTemplate {
case ANNOUNCER_HAS_ANNOUNCED: {
final String id = ((AnnouncePayload) stompMessage.getPayload()).getId();
replayablePayloads.removeIf(message -> {
//noinspection SimplifiableIfStatement
if (!AnnouncePayload.class.isAssignableFrom(message.getPayload().getClass())) {
return false;
}
@ -101,6 +104,7 @@ public class JoalMessageSendingTemplate {
case ANNOUNCER_HAS_FAILED_TO_ANNOUNCE: {
final String id = ((AnnouncePayload) stompMessage.getPayload()).getId();
replayablePayloads.removeIf(message -> {
//noinspection SimplifiableIfStatement
if (!AnnouncePayload.class.isAssignableFrom(message.getPayload().getClass())) {
return false;
}

View file

@ -3,10 +3,10 @@
<Loggers>
<Root level="INFO" additivity="false">
<AppenderRef ref="CONSOLE" />
<AppenderRef ref="CONSOLE"/>
</Root>
<Logger name="org.araymond.joal" level="DEBUG" additivity="false">
<Appender-ref ref="CONSOLE" />
<Appender-ref ref="CONSOLE"/>
</Logger>
</Loggers>

View file

@ -16,8 +16,8 @@ public class PeerIdInfoTest {
final PeerIdInfo peerIdInfo = new PeerIdInfo("-my.pre-", ALPHABETIC, false, false);
assertThat(peerIdInfo.generateNewPeerId())
.startsWith("-my.pre-")
.hasSize(PeerIdInfo.PEER_ID_LENGTH);
.startsWith("-my.pre-")
.hasSize(PeerIdInfo.PEER_ID_LENGTH);
}
@Test

View file

@ -19,15 +19,15 @@ public class JoalConfigProviderTest {
private static final Path resourcePath = Paths.get("src/test/resources/configtest");
public static final AppConfiguration defaultConfig = new AppConfiguration(
180L,
190L,
2,
"azureus-5.7.5.0.client"
180L,
190L,
2,
"azureus-5.7.5.0.client"
);
@Test
public void shouldFailIWithEmptyConfigPath() {
assertThatThrownBy(() ->new JoalConfigProvider(new ObjectMapper(), " "))
assertThatThrownBy(() -> new JoalConfigProvider(new ObjectMapper(), " "))
.isInstanceOf(IllegalArgumentException.class)
.hasMessageContaining("A config path is required.");
}
@ -35,7 +35,7 @@ public class JoalConfigProviderTest {
@Test
public void shouldFailIfJsonFileIsNotPresent() {
final String fakePath = resourcePath.resolve("nop").toString();
assertThatThrownBy(() ->new JoalConfigProvider(new ObjectMapper(), fakePath))
assertThatThrownBy(() -> new JoalConfigProvider(new ObjectMapper(), fakePath))
.isInstanceOf(FileNotFoundException.class)
.hasMessageContaining("App configuration file '" + fakePath + "\\config.json' not found.");
}

View file

@ -1,12 +1,10 @@
package org.araymond.joal.core.events.announce;
import org.araymond.joal.core.ttorent.client.announce.AnnounceResult;
import org.araymond.joal.core.ttorent.client.announce.Announcer;
import org.araymond.joal.core.ttorent.client.bandwidth.TorrentWithStats;
import org.junit.Test;
import org.mockito.Mockito;
import java.util.ArrayList;
import java.util.Collections;
import static org.assertj.core.api.Assertions.assertThat;

View file

@ -9,7 +9,6 @@ import org.mockito.Mockito;
import java.util.Collections;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
/**
* Created by raymo on 25/06/2017.

View file

@ -1,6 +1,5 @@
package org.araymond.joal.core.events.announce;
import com.turn.ttorrent.common.protocol.TrackerMessage;
import org.araymond.joal.core.ttorent.client.announce.Announcer;
import org.araymond.joal.core.ttorent.client.bandwidth.TorrentWithStats;
import org.araymond.joal.web.messages.outgoing.impl.announce.AnnouncePayloadTest;

View file

@ -136,7 +136,7 @@ public class HTTPTrackerClientTest {
final BitTorrentClient bitTorrentClient = Mockito.mock(BitTorrentClient.class);
final ByteBuffer buffer = createValidHttpAnnounceResponseAsByteBuffer().put(0, (byte) 50);
assertThatThrownBy(() ->new HTTPTrackerClient(torrent, peer, uri, bitTorrentClient).toTrackerMessage(buffer))
assertThatThrownBy(() -> new HTTPTrackerClient(torrent, peer, uri, bitTorrentClient).toTrackerMessage(buffer))
.isInstanceOf(AnnounceException.class)
.hasMessage("Error reading tracker response!");
}
@ -147,7 +147,7 @@ public class HTTPTrackerClientTest {
map.put("incomplete", new BEValue(100));
map.put("interval", new BEValue(1800));
map.put("complete", new BEValue(2945));
map.put("peers", new BEValue(new byte[] { 8, 8, 8, 8, 8, 0}));
map.put("peers", new BEValue(new byte[]{8, 8, 8, 8, 8, 0}));
return BEncoder.bencode(map);
}

View file

@ -9,7 +9,6 @@ import com.turn.ttorrent.common.protocol.http.HTTPAnnounceResponseMessage;
import com.turn.ttorrent.common.protocol.http.HTTPTrackerErrorMessage;
import org.araymond.joal.core.ttorent.client.ConnectionHandler;
import org.araymond.joal.core.ttorent.client.announce.AnnounceResponseListener;
import org.araymond.joal.core.ttorent.client.announce.Announcer;
import org.araymond.joal.core.ttorent.client.bandwidth.TorrentWithStats;
import org.assertj.core.util.Lists;
import org.junit.Test;
@ -203,6 +202,7 @@ public class TrackerClientTest {
TorrentWithStats getTorrentWithStats() {
return this.torrent;
}
Peer getPeer() {
return this.peer;
}

View file

@ -150,7 +150,7 @@ public class BandwidthDispatcherTest {
bandwidthDispatcher.stop();
final AppConfiguration conf = configProvider.get();
for (final TorrentWithStats t: torrents) {
for (final TorrentWithStats t : torrents) {
assertThat(t.getUploaded())
.isBetween(
conf.getMinUploadRate() * 1000 / (1000 / updateInterval) / 4,

View file

@ -5,9 +5,6 @@ import org.araymond.joal.web.messages.outgoing.impl.global.SeedSessionHasEndedPa
import org.araymond.joal.web.messages.outgoing.impl.global.SeedSessionHasStartedPayload;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;

View file

@ -2,7 +2,6 @@ package org.araymond.joal.web.messages.outgoing.impl.announce;
import org.araymond.joal.core.events.announce.AnnouncerEvent;
import org.araymond.joal.core.ttorent.client.MockedTorrent;
import org.araymond.joal.core.ttorent.client.announce.Announcer;
import org.araymond.joal.core.ttorent.client.bandwidth.TorrentWithStats;
import org.junit.Test;
import org.mockito.Mockito;

View file

@ -8,7 +8,6 @@ import org.mockito.Mockito;
import java.util.Collections;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
/**
* Created by raymo on 25/06/2017.

View file

@ -8,7 +8,6 @@ import org.mockito.Mockito;
import java.util.Collections;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
/**
* Created by raymo on 25/06/2017.