Skip to content

Commit

Permalink
Bugfix - Remove duplicates in area selector
Browse files Browse the repository at this point in the history
  • Loading branch information
keznikl committed Apr 7, 2014
1 parent 516a23f commit dd3c625
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import cz.cuni.mff.d3s.deeco.DeecoProperties;
import cz.cuni.mff.d3s.deeco.knowledge.ReadOnlyKnowledgeManager;
Expand Down Expand Up @@ -40,7 +42,7 @@ List<String> getRecipientsForTeam(String ownerTeam) {
if (returnAll || (ownerTeam == null)) {
candidateComponents = networkRegistry.getIpEnabledComponents();
} else {
candidateComponents = new ArrayList<>();
candidateComponents = new HashSet<>();

//Find all areas of my team
List<Area> areas = networkRegistry.getTeamSites(ownerTeam);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ protected void init() {
a2 = new RectangularArea("A2", 0, 50, 100, 100, new String[]{"T0", "T2"});
areas = new HashSet<>(Arrays.<Area>asList(a1,a2));

m01 = new Member("M01", "T0", new Position(1, 1), true);
m02 = new Member("M02", "T0", new Position(1, 60), false);
m01 = new Member("M01", "T0", new Position(1, 1), false);
m02 = new Member("M02", "T0", new Position(1, 60), true);
m03 = new Member("M03", "T0", new Position(1, 120), false);
m1 = new Member("M1", "T1", new Position(1, 1), true);
m2 = new Member("M2", "T2", new Position(1, 120), true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void testGetAllComponents(){

@Test
public void testGetIpComponents(){
assertContainsAll(Arrays.<PositionAwareComponent>asList(m01, m1, m2, m0), tested.getIpEnabledComponents());
assertContainsAll(Arrays.<PositionAwareComponent>asList(m02, m1, m2, m0), tested.getIpEnabledComponents());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public void tearDown() {

@Test
public void testGetRecipientsForTeam(){
assertContainsAll(Arrays.<String>asList("M01", "M1", "M2"), tested.getRecipientsForTeam("T0"));
assertContainsAll(Arrays.<String>asList("M01", "M1"), tested.getRecipientsForTeam("T1"));
assertContainsAll(Arrays.<String>asList("M2"), tested.getRecipientsForTeam("T2"));
assertContainsAll(Arrays.<String>asList("M02", "M1", "M2"), tested.getRecipientsForTeam("T0"));
assertContainsAll(Arrays.<String>asList("M02", "M1"), tested.getRecipientsForTeam("T1"));
assertContainsAll(Arrays.<String>asList("M02", "M2"), tested.getRecipientsForTeam("T2"));
assertContainsAll(Arrays.<String>asList("M0"), tested.getRecipientsForTeam("T3"));
}

Expand All @@ -41,10 +41,10 @@ public void testWhenBoundaryDisabled(){
System.setProperty(DeecoProperties.DISABLE_BOUNDARY_CONDITIONS, "true");
tested.initialize(AreaNetworkRegistry.INSTANCE);

assertContainsAll(Arrays.<String>asList("M01", "M1", "M2", "M0"), tested.getRecipientsForTeam("T0"));
assertContainsAll(Arrays.<String>asList("M01", "M1", "M2", "M0"), tested.getRecipientsForTeam("T1"));
assertContainsAll(Arrays.<String>asList("M01", "M1", "M2", "M0"), tested.getRecipientsForTeam("T2"));
assertContainsAll(Arrays.<String>asList("M01", "M1", "M2", "M0"), tested.getRecipientsForTeam("T3"));
assertContainsAll(Arrays.<String>asList("M02", "M1", "M2", "M0"), tested.getRecipientsForTeam("T0"));
assertContainsAll(Arrays.<String>asList("M02", "M1", "M2", "M0"), tested.getRecipientsForTeam("T1"));
assertContainsAll(Arrays.<String>asList("M02", "M1", "M2", "M0"), tested.getRecipientsForTeam("T2"));
assertContainsAll(Arrays.<String>asList("M02", "M1", "M2", "M0"), tested.getRecipientsForTeam("T3"));
}


Expand Down

0 comments on commit dd3c625

Please sign in to comment.