Skip to content
Snippets Groups Projects
Commit 11065816 authored by Nelson Tavares de Sousa's avatar Nelson Tavares de Sousa
Browse files

removed some more pmd issues

parent ee0a3e8a
Branches
Tags
No related merge requests found
...@@ -41,58 +41,60 @@ public class DistributorTest { ...@@ -41,58 +41,60 @@ public class DistributorTest {
public ExpectedException expectedException = ExpectedException.none(); public ExpectedException expectedException = ExpectedException.none();
private Distributor<Integer> distributor; private Distributor<Integer> distributor;
private List<Integer> fstList; private List<Integer> firstIntegers;
private List<Integer> sndList; private List<Integer> secondIntegers;
@Before @Before
public void initializeDistributor() throws Exception { public void initializeDistributor() throws Exception {
this.distributor = new Distributor<Integer>(); this.distributor = new Distributor<Integer>();
this.fstList = new ArrayList<Integer>(); this.firstIntegers = new ArrayList<Integer>();
this.sndList = new ArrayList<Integer>(); this.secondIntegers = new ArrayList<Integer>();
} }
@Test @Test
public void roundRobinShouldWork() { public void roundRobinShouldWork() {
distributor.setStrategy(new RoundRobinStrategy()); distributor.setStrategy(new RoundRobinStrategy());
test(distributor).and().send(1, 2, 3, 4, 5).to(distributor.getInputPort()).and().receive(fstList).from(distributor.getNewOutputPort()).and() test(distributor).and().send(1, 2, 3, 4, 5).to(distributor.getInputPort()).and().receive(firstIntegers).from(distributor.getNewOutputPort()).and()
.receive(sndList).from(distributor.getNewOutputPort()).start(); .receive(secondIntegers).from(distributor.getNewOutputPort()).start();
assertThat(this.fstList, contains(1, 3, 5)); assertThat(this.firstIntegers, contains(1, 3, 5));
assertThat(this.sndList, contains(2, 4)); assertThat(this.secondIntegers, contains(2, 4));
} }
@Test @Test
public void singleElementRoundRobinShouldWork() { public void singleElementRoundRobinShouldWork() {
distributor.setStrategy(new RoundRobinStrategy()); distributor.setStrategy(new RoundRobinStrategy());
test(distributor).and().send(1).to(distributor.getInputPort()).and().receive(fstList).from(distributor.getNewOutputPort()).and().receive(sndList) test(distributor).and().send(1).to(distributor.getInputPort()).and().receive(firstIntegers).from(distributor.getNewOutputPort()).and()
.receive(secondIntegers)
.from(distributor.getNewOutputPort()).start(); .from(distributor.getNewOutputPort()).start();
assertThat(this.fstList, contains(1)); assertThat(this.firstIntegers, contains(1));
assertThat(this.sndList, is(empty())); assertThat(this.secondIntegers, is(empty()));
} }
@Test @Test
public void copyByReferenceShouldWork() { public void copyByReferenceShouldWork() {
distributor.setStrategy(new CopyByReferenceStrategy()); distributor.setStrategy(new CopyByReferenceStrategy());
test(distributor).and().send(1, 2, 3, 4, 5).to(distributor.getInputPort()).and().receive(fstList).from(distributor.getNewOutputPort()).and() test(distributor).and().send(1, 2, 3, 4, 5).to(distributor.getInputPort()).and().receive(firstIntegers).from(distributor.getNewOutputPort()).and()
.receive(sndList).from(distributor.getNewOutputPort()).start(); .receive(secondIntegers).from(distributor.getNewOutputPort()).start();
assertThat(this.fstList, contains(1, 2, 3, 4, 5)); assertThat(this.firstIntegers, contains(1, 2, 3, 4, 5));
assertThat(this.sndList, contains(1, 2, 3, 4, 5)); assertThat(this.secondIntegers, contains(1, 2, 3, 4, 5));
} }
@Test @Test
public void singleElementCopyByReferenceShouldWork() { public void singleElementCopyByReferenceShouldWork() {
distributor.setStrategy(new CopyByReferenceStrategy()); distributor.setStrategy(new CopyByReferenceStrategy());
test(distributor).and().send(1).to(distributor.getInputPort()).and().receive(fstList).from(distributor.getNewOutputPort()).and().receive(sndList) test(distributor).and().send(1).to(distributor.getInputPort()).and().receive(firstIntegers).from(distributor.getNewOutputPort()).and()
.receive(secondIntegers)
.from(distributor.getNewOutputPort()).start(); .from(distributor.getNewOutputPort()).start();
assertThat(this.fstList, contains(1)); assertThat(this.firstIntegers, contains(1));
assertThat(this.sndList, contains(1)); assertThat(this.secondIntegers, contains(1));
} }
@Test @Test
......
...@@ -30,20 +30,20 @@ public class FileSearcherTest { ...@@ -30,20 +30,20 @@ public class FileSearcherTest {
@Test @Test
public void fileInClasspath() throws IOException { public void fileInClasspath() throws IOException {
final List<URL> list = FileSearcher.loadResources("pipe-factories.conf"); final List<URL> urls = FileSearcher.loadResources("pipe-factories.conf");
Assert.assertEquals(false, list.isEmpty()); Assert.assertEquals(false, urls.isEmpty());
} }
@Test @Test
public void multipleFiles() throws IOException { public void multipleFiles() throws IOException {
final List<URL> list = FileSearcher.loadResources("LICENSE.txt"); final List<URL> urls = FileSearcher.loadResources("LICENSE.txt");
Assert.assertEquals(true, list.size() > 1); Assert.assertEquals(true, urls.size() > 1);
} }
@Test @Test
public void missingFile() throws IOException { public void missingFile() throws IOException {
final List<URL> list = FileSearcher.loadResources("filethatdoesnotexistinanyproject.nope"); final List<URL> urls = FileSearcher.loadResources("filethatdoesnotexistinanyproject.nope");
Assert.assertEquals(true, list.isEmpty()); Assert.assertEquals(true, urls.isEmpty());
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment