GBP tests: fixes for unnecessary mocking, method naming and other 57/38057/4
authorKonstantin Blagov <kblagov@cisco.com>
Mon, 25 Apr 2016 13:21:45 +0000 (15:21 +0200)
committerKonstantin Blagov <kblagov@cisco.com>
Mon, 16 May 2016 12:59:02 +0000 (12:59 +0000)
improvements

Change-Id: I69c75e13b87c3a22c5cb937395d5e3386dc37f2a
Signed-off-by: Konstantin Blagov <kblagov@cisco.com>
15 files changed:
groupbasedpolicy/src/main/java/org/opendaylight/groupbasedpolicy/dto/ValidationResultBuilder.java
groupbasedpolicy/src/test/java/org/opendaylight/groupbasedpolicy/endpoint/EpKeyTest.java [changed mode: 0644->0755]
groupbasedpolicy/src/test/java/org/opendaylight/groupbasedpolicy/resolver/ConditionGroupTest.java [changed mode: 0644->0755]
groupbasedpolicy/src/test/java/org/opendaylight/groupbasedpolicy/resolver/ConditionSetTest.java [changed mode: 0644->0755]
groupbasedpolicy/src/test/java/org/opendaylight/groupbasedpolicy/resolver/EgKeyTest.java [changed mode: 0644->0755]
groupbasedpolicy/src/test/java/org/opendaylight/groupbasedpolicy/resolver/EndpointConstraintTest.java [changed mode: 0644->0755]
groupbasedpolicy/src/test/java/org/opendaylight/groupbasedpolicy/resolver/EpgKeyDtoTest.java
groupbasedpolicy/src/test/java/org/opendaylight/groupbasedpolicy/resolver/IndexedTenantTest.java [changed mode: 0644->0755]
groupbasedpolicy/src/test/java/org/opendaylight/groupbasedpolicy/resolver/InheritanceUtilsTest.java [changed mode: 0644->0755]
groupbasedpolicy/src/test/java/org/opendaylight/groupbasedpolicy/resolver/PolicyInfoTest.java [changed mode: 0644->0755]
groupbasedpolicy/src/test/java/org/opendaylight/groupbasedpolicy/resolver/PolicyResolverUtilsTest.java [changed mode: 0644->0755]
groupbasedpolicy/src/test/java/org/opendaylight/groupbasedpolicy/resolver/RuleGroupTest.java [changed mode: 0644->0755]
groupbasedpolicy/src/test/java/org/opendaylight/groupbasedpolicy/resolver/validator/ValidationResultTest.java [changed mode: 0644->0755]
groupbasedpolicy/src/test/java/org/opendaylight/groupbasedpolicy/util/DataStoreHelperTest.java [changed mode: 0644->0755]
groupbasedpolicy/src/test/java/org/opendaylight/groupbasedpolicy/util/SetUtilsTest.java [changed mode: 0644->0755]

index 75237fe4988c61291765699a6965a3c174e08221..3e22b658ac751dbfaa01c5ebfd3fcd567dd58477 100755 (executable)
@@ -7,7 +7,6 @@
  */\r
 package org.opendaylight.groupbasedpolicy.dto;\r
 \r
-\r
 import javax.annotation.Nonnull;\r
 \r
 import org.opendaylight.groupbasedpolicy.api.ValidationResult;\r
@@ -15,6 +14,8 @@ import org.opendaylight.yangtools.concepts.Builder;
 \r
 public final class ValidationResultBuilder implements Builder<ValidationResult> {\r
 \r
+    public static final String ILLEGAL_ARG_EX_MSG = "Result message cannot be set to NULL!";\r
+\r
     private static final class ValidationResultImpl implements ValidationResult {\r
 \r
         private final boolean success;\r
@@ -81,7 +82,7 @@ public final class ValidationResultBuilder implements Builder<ValidationResult>
      */\r
     public ValidationResultBuilder setMessage(@Nonnull String message) {\r
         if (message == null) {\r
-            throw new IllegalArgumentException("Result message cannot be set to NULL!");\r
+            throw new IllegalArgumentException(ILLEGAL_ARG_EX_MSG);\r
         }\r
         this.message = message;\r
         return this;\r
old mode 100644 (file)
new mode 100755 (executable)
index 4a43a68..aca88f5
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- * 
+ *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
@@ -8,8 +8,6 @@
 
 package org.opendaylight.groupbasedpolicy.endpoint;
 
-import static org.mockito.Mockito.mock;
-
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -20,33 +18,31 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev
 public class EpKeyTest {
 
     private EpKey epKey;
-
     private L2ContextId l2Context;
     private MacAddress macAddress;
 
     @Before
-    public void initialisation() {
-        l2Context = mock(L2ContextId.class);
-        macAddress = mock(MacAddress.class);
-
+    public void init() {
+        l2Context = new L2ContextId("l2ctxId");
+        macAddress = new MacAddress("00:00:00:00:00:01");
         epKey = new EpKey(l2Context, macAddress);
     }
 
     @Test
-    public void constructorTest() {
+    public void testConstructor() {
         Assert.assertEquals(l2Context, epKey.getL2Context());
         Assert.assertEquals(macAddress, epKey.getMacAddress());
     }
 
     @Test
-    public void equalsTest() {
+    public void testEquals() {
         Assert.assertTrue(epKey.equals(epKey));
         Assert.assertFalse(epKey.equals(null));
         Assert.assertFalse(epKey.equals(new Object()));
 
         EpKey other;
-        MacAddress macAddressOther = mock(MacAddress.class);
-        L2ContextId l2ContextIdOther = mock(L2ContextId.class);
+        MacAddress macAddressOther = new MacAddress("00:00:00:00:00:02");;
+        L2ContextId l2ContextIdOther = new L2ContextId("l2ctxId-other");
         other = new EpKey(l2Context, macAddressOther);
         Assert.assertFalse(epKey.equals(other));
         other = new EpKey(l2ContextIdOther, macAddress);
@@ -65,7 +61,7 @@ public class EpKeyTest {
     }
 
     @Test
-    public void toStringTest() {
+    public void testToString() {
         Assert.assertNotNull(epKey.toString());
     }
 }
old mode 100644 (file)
new mode 100755 (executable)
index f9a0b68..bf1b81c
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- * 
+ *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
@@ -8,12 +8,14 @@
 
 package org.opendaylight.groupbasedpolicy.resolver;
 
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.mock;
 
 import java.util.Collections;
 import java.util.Set;
 
-import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.groupbasedpolicy.dto.ConditionGroup;
@@ -24,36 +26,33 @@ public class ConditionGroupTest {
     private ConditionGroup conditionGroup;
 
     private ConditionSet conditionSet;
-    private Set<ConditionSet> conditionSetSet;
 
     @Before
-    public void initialisation() {
+    public void init() {
         conditionSet = mock(ConditionSet.class);
-        conditionSetSet = Collections.singleton(conditionSet);
-
-        conditionGroup = new ConditionGroup(conditionSetSet);
+        conditionGroup = new ConditionGroup(Collections.singleton(conditionSet));
     }
 
     @Test
-    public void constructorTest() {
-        Assert.assertTrue(conditionGroup.contains(conditionSet));
+    public void testConstructor() {
+        assertTrue(conditionGroup.contains(conditionSet));
     }
 
     @Test
-    public void equalsTest() {
-        Assert.assertTrue(conditionGroup.equals(conditionGroup));
-        Assert.assertFalse(conditionGroup.equals(null));
-        Assert.assertFalse(conditionGroup.equals(new Object()));
+    public void testEquals() {
+        assertTrue(conditionGroup.equals(conditionGroup));
+        assertFalse(conditionGroup.equals(null));
+        assertFalse(conditionGroup.equals(new Object()));
 
         ConditionSet conditionSet = mock(ConditionSet.class);
         Set<ConditionSet> conditionSetSetOther = Collections.singleton(conditionSet);
         ConditionGroup other;
         other = new ConditionGroup(conditionSetSetOther);
-        Assert.assertFalse(conditionGroup.equals(other));
+        assertFalse(conditionGroup.equals(other));
     }
 
     @Test
-    public void toStringTest() {
-        Assert.assertNotNull(conditionGroup.toString());
+    public void testToString() {
+        assertNotNull(conditionGroup.toString());
     }
 }
old mode 100644 (file)
new mode 100755 (executable)
index 7ecfa0b..1c6aaaa
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- * 
+ *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
@@ -8,14 +8,14 @@
 
 package org.opendaylight.groupbasedpolicy.resolver;
 
-import static org.mockito.Mockito.mock;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
-import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 import java.util.Set;
 
-import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.groupbasedpolicy.dto.ConditionSet;
@@ -23,55 +23,55 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev
 
 public class ConditionSetTest {
 
-    private ConditionSet conditionSet;
+    private static final String CONDITION1 = "condition1";
+    private static final String CONDITION2 = "condition2";
 
+    private ConditionSet conditionSet;
     private ConditionName conditionName;
     private Set<ConditionName> conditionNameSet;
     private Set<Set<ConditionName>> anySet;
 
     @Before
-    public void initialisation() {
-        conditionName = mock(ConditionName.class);
+    public void init() {
+        conditionName = new ConditionName(CONDITION1);
         conditionNameSet = Collections.singleton(conditionName);
         anySet = Collections.singleton(conditionNameSet);
         conditionSet = new ConditionSet(conditionNameSet, conditionNameSet, anySet);
     }
 
     @Test
-    public void matchesTest() {
-        List<ConditionName> conditionNameList;
-        conditionNameList = Arrays.asList(conditionName);
-        Assert.assertFalse(conditionSet.matches(conditionNameList));
-
-        ConditionName conditionNameOther;
-        conditionNameOther = mock(ConditionName.class);
-        conditionNameList = Arrays.asList(conditionNameOther);
-        Assert.assertFalse(conditionSet.matches(conditionNameList));
+    public void testMatches() {
+        List<ConditionName> conditionNameList = Collections.singletonList(conditionName);
+        assertFalse(conditionSet.matches(conditionNameList));
+
+        ConditionName conditionNameOther = new ConditionName(CONDITION2);
+        conditionNameList = Collections.singletonList(conditionNameOther);
+        assertFalse(conditionSet.matches(conditionNameList));
     }
 
     @Test
-    public void equalsTest() {
-        Assert.assertTrue(conditionSet.equals(conditionSet));
-        Assert.assertFalse(conditionSet.equals(null));
-        Assert.assertFalse(conditionSet.equals(new Object()));
+    public void testEquals() {
+        assertTrue(conditionSet.equals(conditionSet));
+        assertFalse(conditionSet.equals(null));
+        assertFalse(conditionSet.equals(new Object()));
 
         ConditionSet other;
         other = ConditionSet.EMPTY;
-        Assert.assertFalse(conditionSet.equals(other));
+        assertFalse(conditionSet.equals(other));
 
         other = new ConditionSet(conditionNameSet, Collections.<ConditionName>emptySet(),
                 Collections.<Set<ConditionName>>emptySet());
-        Assert.assertFalse(conditionSet.equals(other));
+        assertFalse(conditionSet.equals(other));
 
         other = new ConditionSet(conditionNameSet, Collections.<ConditionName>emptySet(), anySet);
-        Assert.assertFalse(conditionSet.equals(other));
+        assertFalse(conditionSet.equals(other));
 
         other = new ConditionSet(conditionNameSet, conditionNameSet, anySet);
-        Assert.assertTrue(conditionSet.equals(other));
+        assertTrue(conditionSet.equals(other));
     }
 
     @Test
-    public void toStringTest() {
-        Assert.assertNotNull(conditionSet.toString());
+    public void testToString() {
+        assertNotNull(conditionSet.toString());
     }
 }
old mode 100644 (file)
new mode 100755 (executable)
index 84106c8..812b2d2
@@ -1,9 +1,12 @@
 package org.opendaylight.groupbasedpolicy.resolver;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
-import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.groupbasedpolicy.dto.EgKey;
@@ -15,14 +18,13 @@ public class EgKeyTest {
     private EgKey egKey;
     private TenantId tenantId;
     private EndpointGroupId egId;
-    private String value;
 
     @Before
-    public void initialisation() {
+    public void init() {
         tenantId = mock(TenantId.class);
         egId = mock(EndpointGroupId.class);
 
-        value = "value";
+        String value = "value";
         when(tenantId.getValue()).thenReturn(value);
         when(egId.getValue()).thenReturn(value);
 
@@ -30,67 +32,69 @@ public class EgKeyTest {
     }
 
     @Test
-    public void constructorTest() {
-        Assert.assertEquals(tenantId, egKey.getTenantId());
-        Assert.assertEquals(egId, egKey.getEgId());
+    public void testConstructor() {
+        assertEquals(tenantId, egKey.getTenantId());
+        assertEquals(egId, egKey.getEgId());
     }
 
     @Test
-    public void equalsTest() {
-        Assert.assertTrue(egKey.equals(egKey));
-        Assert.assertFalse(egKey.equals(null));
-        Assert.assertFalse(egKey.equals(new Object()));
+    public void testEquals() {
+        assertTrue(egKey.equals(egKey));
+        assertFalse(egKey.equals(null));
+        assertFalse(egKey.equals(new Object()));
 
         EgKey other;
         other = new EgKey(null, egId);
-        Assert.assertFalse(egKey.equals(other));
-        Assert.assertFalse(other.equals(egKey));
+        assertFalse(egKey.equals(other));
+        assertFalse(other.equals(egKey));
 
         other = new EgKey(tenantId, null);
-        Assert.assertFalse(egKey.equals(other));
-        Assert.assertFalse(other.equals(egKey));
+        assertFalse(egKey.equals(other));
+        assertFalse(other.equals(egKey));
 
         other = new EgKey(tenantId, egId);
-        Assert.assertTrue(egKey.equals(other));
+        assertTrue(egKey.equals(other));
 
         egKey = new EgKey(null, null);
         other = new EgKey(null, null);
-        Assert.assertTrue(egKey.equals(other));
+        assertTrue(egKey.equals(other));
     }
 
     @Test
-    public void compareToTest() {
+    public void testCompareTo() {
         EgKey other = new EgKey(tenantId, egId);
-        Assert.assertEquals(0, egKey.compareTo(other));
+        assertEquals(0, egKey.compareTo(other));
 
         other = new EgKey(null, null);
-        Assert.assertEquals(-1, egKey.compareTo(other));
-        Assert.assertEquals(1, other.compareTo(egKey));
+        assertEquals(-1, egKey.compareTo(other));
+        assertEquals(1, other.compareTo(egKey));
 
         String valueOther = "valu";
         TenantId tenantIdOther = mock(TenantId.class);
         when(tenantIdOther.getValue()).thenReturn(valueOther);
+
         other = new EgKey(tenantIdOther, egId);
-        Assert.assertEquals(1, egKey.compareTo(other));
-        Assert.assertEquals(-1, other.compareTo(egKey));
+        assertEquals(1, egKey.compareTo(other));
+        assertEquals(-1, other.compareTo(egKey));
 
         EndpointGroupId egIdOther = mock(EndpointGroupId.class);
         when(egIdOther.getValue()).thenReturn(valueOther);
+
         other = new EgKey(tenantId, egIdOther);
-        Assert.assertEquals(1, egKey.compareTo(other));
-        Assert.assertEquals(-1, other.compareTo(egKey));
+        assertEquals(1, egKey.compareTo(other));
+        assertEquals(-1, other.compareTo(egKey));
 
         egKey = new EgKey(tenantIdOther, egId);
-        Assert.assertEquals(-1, egKey.compareTo(other));
-        Assert.assertEquals(1, other.compareTo(egKey));
+        assertEquals(-1, egKey.compareTo(other));
+        assertEquals(1, other.compareTo(egKey));
     }
 
     @Test
-    public void toStringTest() {
+    public void testToString() {
         String string = egKey.toString();
-        Assert.assertNotNull(string);
-        Assert.assertFalse(string.isEmpty());
-        Assert.assertTrue(string.contains(tenantId.toString()));
-        Assert.assertTrue(string.contains(egId.toString()));
+        assertNotNull(string);
+        assertFalse(string.isEmpty());
+        assertTrue(string.contains(tenantId.toString()));
+        assertTrue(string.contains(egId.toString()));
     }
 }
old mode 100644 (file)
new mode 100755 (executable)
index 642a456..17093d3
@@ -8,24 +8,31 @@
 
 package org.opendaylight.groupbasedpolicy.resolver;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
 
-import java.util.Arrays;
+import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
-import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.groupbasedpolicy.dto.ConditionSet;
 import org.opendaylight.groupbasedpolicy.dto.EndpointConstraint;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ConditionName;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.has.endpoint.identification.constraints.EndpointIdentificationConstraints;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.has.endpoint.identification.constraints.EndpointIdentificationConstraintsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.has.endpoint.identification.constraints.endpoint.identification.constraints.L3EndpointIdentificationConstraints;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.has.endpoint.identification.constraints.endpoint.identification.constraints.L3EndpointIdentificationConstraintsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.has.endpoint.identification.constraints.endpoint.identification.constraints.l3.endpoint.identification.constraints.PrefixConstraint;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.has.endpoint.identification.constraints.endpoint.identification.constraints.l3.endpoint.identification.constraints.PrefixConstraintBuilder;
 
 public class EndpointConstraintTest {
 
@@ -35,67 +42,71 @@ public class EndpointConstraintTest {
     private EndpointIdentificationConstraints consEpIdentificationConstraint;
     private L3EndpointIdentificationConstraints l3Constraints;
     private PrefixConstraint prefixConstraint;
+    private IpPrefix ipPrefix;
 
     @Before
-    public void initialise() {
+    public void init() {
         conditionSet = mock(ConditionSet.class);
-        consEpIdentificationConstraint = mock(EndpointIdentificationConstraints.class);
-        l3Constraints = mock(L3EndpointIdentificationConstraints.class);
-        when(consEpIdentificationConstraint.getL3EndpointIdentificationConstraints()).thenReturn(l3Constraints);
-        prefixConstraint = mock(PrefixConstraint.class);
-        when(l3Constraints.getPrefixConstraint()).thenReturn(Arrays.asList(prefixConstraint));
+
+        ipPrefix = new IpPrefix(new Ipv4Prefix("10.0.0.0/8"));
+        prefixConstraint = new PrefixConstraintBuilder().setIpPrefix(ipPrefix).build();
+        l3Constraints = new L3EndpointIdentificationConstraintsBuilder().setPrefixConstraint(
+                Collections.singletonList(prefixConstraint)).build();
+        consEpIdentificationConstraint =
+                new EndpointIdentificationConstraintsBuilder().setL3EndpointIdentificationConstraints(
+                        l3Constraints).build();
 
         constraint = new EndpointConstraint(conditionSet, consEpIdentificationConstraint);
     }
 
     @Test
-    public void conditionsMatchTest() {
-        ConditionName conditionName = mock(ConditionName.class);
-        List<ConditionName> epConditions = Arrays.asList(conditionName);
-        when(conditionSet.matches(epConditions)).thenReturn(true);
-        Assert.assertTrue(constraint.conditionsMatch(epConditions));
+    public void testConstructor() {
+        assertEquals(conditionSet, constraint.getConditionSet());
+        assertTrue(constraint.getL3EpPrefixes().contains(prefixConstraint));
+        assertNotNull(constraint.hashCode());
+
+        constraint = new EndpointConstraint(null, consEpIdentificationConstraint);
+        assertEquals(ConditionSet.EMPTY, constraint.getConditionSet());
     }
 
     @Test
-    public void constructorTest() {
-        Assert.assertEquals(conditionSet, constraint.getConditionSet());
-        Assert.assertTrue(constraint.getL3EpPrefixes().contains(prefixConstraint));
-        Assert.assertNotNull(constraint.hashCode());
+    public void testConditionsMatch() {
+        ConditionName conditionName = new ConditionName("condition1");
+        List<ConditionName> epConditions = Collections.singletonList(conditionName);
+        when(conditionSet.matches(epConditions)).thenReturn(true);
 
-        constraint = new EndpointConstraint(null, consEpIdentificationConstraint);
-        Assert.assertEquals(ConditionSet.EMPTY, constraint.getConditionSet());
+        assertTrue(constraint.conditionsMatch(epConditions));
     }
 
+
     @Test
-    public void getIpPrefixesFromTest() {
-        PrefixConstraint prefixConstraint = mock(PrefixConstraint.class);
-        IpPrefix ipPrefix = mock(IpPrefix.class);
-        when(prefixConstraint.getIpPrefix()).thenReturn(ipPrefix);
-        Set<PrefixConstraint> prefixConstraints = new HashSet<PrefixConstraint>();
+    public void testGetIpPrefixesFrom() {
+        Set<PrefixConstraint> prefixConstraints = new HashSet<>();
         prefixConstraints.add(prefixConstraint);
 
         Set<IpPrefix> ipPrefixes = EndpointConstraint.getIpPrefixesFrom(prefixConstraints);
-        Assert.assertEquals(1, ipPrefixes.size());
-        Assert.assertTrue(ipPrefixes.contains(ipPrefix));
+
+        assertEquals(1, ipPrefixes.size());
+        assertTrue(ipPrefixes.contains(ipPrefix));
     }
 
     @Test
-    public void equalsTest() {
-        Assert.assertTrue(constraint.equals(constraint));
-        Assert.assertFalse(constraint.equals(null));
-        Assert.assertFalse(constraint.equals(new Object()));
+    public void testEquals() {
+        assertTrue(constraint.equals(constraint));
+        assertFalse(constraint.equals(null));
+        assertFalse(constraint.equals(new Object()));
 
         EndpointConstraint other;
         ConditionSet conditionSetOther = mock(ConditionSet.class);
         EndpointIdentificationConstraints consEpIdentificationConstraintOther = mock(EndpointIdentificationConstraints.class);
 
         other = new EndpointConstraint(conditionSet, consEpIdentificationConstraintOther);
-        Assert.assertFalse(constraint.equals(other));
+        assertFalse(constraint.equals(other));
 
         other = new EndpointConstraint(conditionSetOther, consEpIdentificationConstraint);
-        Assert.assertFalse(constraint.equals(other));
+        assertFalse(constraint.equals(other));
 
         other = new EndpointConstraint(conditionSet, consEpIdentificationConstraint);
-        Assert.assertTrue(constraint.equals(other));
+        assertTrue(constraint.equals(other));
     }
 }
index 4604f698a569000f83017c9dfa1a596b1119ebfa..e50ca35a53ac445c5309d107c2bfa25f0f0a2e22 100755 (executable)
@@ -1,6 +1,6 @@
 package org.opendaylight.groupbasedpolicy.resolver;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
 
 import org.junit.Before;
 import org.junit.Rule;
old mode 100644 (file)
new mode 100755 (executable)
index 7efbe1a..1e0a0a3
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
- * 
+ *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
@@ -13,10 +13,9 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
 
-import java.util.Arrays;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.List;
 
 import org.junit.Before;
@@ -36,6 +35,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.ForwardingContext;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.ForwardingContextBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.Policy;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.PolicyBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.forwarding.context.L2BridgeDomain;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.forwarding.context.L2BridgeDomainBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.forwarding.context.L2FloodDomain;
@@ -45,154 +45,155 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.forwarding.context.Subnet;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.forwarding.context.SubnetBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.Contract;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.ContractBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.EndpointGroup;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.EndpointGroupBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.SubjectFeatureInstances;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.SubjectFeatureInstancesBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.subject.feature.instances.ActionInstance;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.subject.feature.instances.ActionInstanceBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.subject.feature.instances.ClassifierInstance;
 
 import com.google.common.collect.ImmutableList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.subject.feature.instances.ClassifierInstanceBuilder;
 
 public class IndexedTenantTest {
 
     private Tenant tenant;
     private Policy policy;
-    private ForwardingContext fwCtx;
+    private EndpointGroup eg;
+    private Contract contract;
+    private L3Context l3;
+    private L2BridgeDomain bd;
+    private L2FloodDomain fd;
+    private ClassifierInstance ci;
+    private ActionInstance ai;
+    private EndpointGroupId egId;
+    private L3ContextId l3id;
+    private L2BridgeDomainId bdid;
+    private L2FloodDomainId fdid;
+    private ContractId contractId;
+    private ClassifierName ciName;
+    private ActionName actionName;
 
     @Before
-    public void before() {
-        tenant = mock(Tenant.class);
-        policy = mock(Policy.class);
-        fwCtx = mock(ForwardingContext.class);
-        when(tenant.getPolicy()).thenReturn(policy);
-        when(tenant.getForwardingContext()).thenReturn(fwCtx);
+    public void init() {
+        egId = new EndpointGroupId("endpointGroupID");
+        eg = new EndpointGroupBuilder().setId(egId).build();
+        List<EndpointGroup> egList = Collections.singletonList(eg);
+
+        contractId = new ContractId("contractID");
+        contract = new ContractBuilder().setId(contractId).build();
+        List<Contract> contractList = Collections.singletonList(contract);
+
+        l3id = new L3ContextId("contextID");
+        l3 = new L3ContextBuilder().setId(l3id).build();
+        List<L3Context> l3ctxList = Collections.singletonList(l3);
+
+        bdid = new L2BridgeDomainId("bridgeDomainID");
+        bd = new L2BridgeDomainBuilder().setId(bdid).build();
+        List<L2BridgeDomain> l2BridgeDomainList = Collections.singletonList(bd);
+
+        fdid = new L2FloodDomainId("floodDomainID");
+        fd = new L2FloodDomainBuilder().setId(fdid).build();
+        List<L2FloodDomain> l2FloodDomainList = Collections.singletonList(fd);
+
+        SubnetId subnetId = new SubnetId("subnetID");
+        ContextId sParent = new ContextId("sParentValue");
+        Subnet subnet = new SubnetBuilder().setId(subnetId).setParent(sParent).build();
+        List<Subnet> subnetList = Collections.singletonList(subnet);
+
+        ciName = new ClassifierName("ciName");
+        ci = new ClassifierInstanceBuilder().setName(ciName).build();
+        List<ClassifierInstance> ciList = Collections.singletonList(ci);
+        actionName = new ActionName("actionName");
+        ai = new ActionInstanceBuilder().setName(actionName).build();
+        List<ActionInstance> actionList = Collections.singletonList(ai);
+        SubjectFeatureInstances sfi =
+                new SubjectFeatureInstancesBuilder().setClassifierInstance(ciList)
+                        .setActionInstance(actionList)
+                        .build();
+
+        policy = new PolicyBuilder().setEndpointGroup(egList)
+                .setContract(contractList)
+                .setSubjectFeatureInstances(sfi)
+                .build();
+        ForwardingContext fwCtx = new ForwardingContextBuilder().setL3Context(l3ctxList)
+                .setL2BridgeDomain(l2BridgeDomainList)
+                .setL2FloodDomain(l2FloodDomainList)
+                .setSubnet(subnetList)
+                .build();
+        tenant = new TenantBuilder().setPolicy(policy).setForwardingContext(fwCtx).build();
     }
 
     @Test
-    public void testResolveND() throws Exception {
-        SubnetId sid = new SubnetId("dd25397d-d829-4c8d-8c01-31f129b8de8f");
-        SubnetId sid2 = new SubnetId("c752ba40-40aa-4a47-8138-9b7175b854fa");
-        L3ContextId l3id = new L3ContextId("f2311f52-890f-4095-8b85-485ec8b92b3c");
-        L2BridgeDomainId bdid = new L2BridgeDomainId("70aeb9ea-4ca1-4fb9-9780-22b04b84a0d6");
-        L2FloodDomainId fdid = new L2FloodDomainId("252fbac6-bb6e-4d16-808d-6f56d20e5cca");
-
-        L3Context l3c = new L3ContextBuilder().setId(l3id).build();
-        L2BridgeDomain bd = new L2BridgeDomainBuilder().setParent(l3id).setId(bdid).build();
-        L2FloodDomain fd = new L2FloodDomainBuilder().setParent(bdid).setId(fdid).build();
-        Subnet s = new SubnetBuilder().setParent(fdid).setId(sid).build();
-        Subnet s2 = new SubnetBuilder().setParent(bdid).setId(sid2).build();
-        Tenant t = new TenantBuilder()
-            .setForwardingContext(new ForwardingContextBuilder().setSubnet(ImmutableList.of(s, s2))
-                .setL2BridgeDomain(ImmutableList.of(bd))
-                .setL3Context(ImmutableList.of(l3c))
-                .setL2FloodDomain(ImmutableList.of(fd))
-                .build())
-            .build();
-        IndexedTenant it = new IndexedTenant(t);
-
-        assertNotNull(it.getNetworkDomain(sid));
-        Collection<Subnet> sns = it.resolveSubnets(sid);
-        assertTrue(sns.contains(s));
-        assertTrue(sns.contains(s2));
-        assertEquals(l3id, it.resolveL3Context(sid).getId());
-        assertEquals(bdid, it.resolveL2BridgeDomain(sid).getId());
-        assertEquals(fdid, it.resolveL2FloodDomain(sid).getId());
-    }
-
-    @Test
-    public void constructorTest() {
-        EndpointGroup eg = mock(EndpointGroup.class);
-        List<EndpointGroup> egList = Arrays.asList(eg);
-        when(policy.getEndpointGroup()).thenReturn(egList);
-        EndpointGroupId egId = mock(EndpointGroupId.class);
-        when(eg.getId()).thenReturn(egId);
-
-        Contract contract = mock(Contract.class);
-        List<Contract> contractList = Arrays.asList(contract);
-        when(policy.getContract()).thenReturn(contractList);
-        ContractId contractId = mock(ContractId.class);
-        when(contract.getId()).thenReturn(contractId);
-
-        L3Context l3Context = mock(L3Context.class);
-        List<L3Context> l3ContextList = Arrays.asList(l3Context);
-        when(fwCtx.getL3Context()).thenReturn(l3ContextList);
-        L3ContextId l3ContextId = mock(L3ContextId.class);
-        when(l3Context.getId()).thenReturn(l3ContextId);
-        String l3ContextValue = "contextID";
-        when(l3ContextId.getValue()).thenReturn(l3ContextValue);
-
-        L2BridgeDomain l2BridgeDomain = mock(L2BridgeDomain.class);
-        List<L2BridgeDomain> l2BridgeDomainList = Arrays.asList(l2BridgeDomain);
-        when(fwCtx.getL2BridgeDomain()).thenReturn(l2BridgeDomainList);
-        L2BridgeDomainId l2BridgeDomainId = mock(L2BridgeDomainId.class);
-        when(l2BridgeDomain.getId()).thenReturn(l2BridgeDomainId);
-        String l2BridgeDomainIdValue = "bridgeDomainID";
-        when(l2BridgeDomainId.getValue()).thenReturn(l2BridgeDomainIdValue);
-
-        L2FloodDomain l2FloodDomain = mock(L2FloodDomain.class);
-        List<L2FloodDomain> l2FloodDomainList = Arrays.asList(l2FloodDomain);
-        when(fwCtx.getL2FloodDomain()).thenReturn(l2FloodDomainList);
-        L2FloodDomainId l2FloodDomainId = mock(L2FloodDomainId.class);
-        when(l2FloodDomain.getId()).thenReturn(l2FloodDomainId);
-        String cValue = "floodDomainID";
-        when(l2FloodDomainId.getValue()).thenReturn(cValue);
-
-        Subnet subnet = mock(Subnet.class);
-        List<Subnet> subnetList = Arrays.asList(subnet);
-        when(fwCtx.getSubnet()).thenReturn(subnetList);
-        SubnetId subnetId = mock(SubnetId.class);
-        when(subnet.getId()).thenReturn(subnetId);
-        String subnetIdValue = "subnetID";
-        when(subnetId.getValue()).thenReturn(subnetIdValue);
-        ContextId sParent = mock(ContextId.class);
-        when(subnet.getParent()).thenReturn(sParent);
-        String sParentValue = "sParentValue";
-        when(sParent.getValue()).thenReturn(sParentValue);
-
-        SubjectFeatureInstances sfi = mock(SubjectFeatureInstances.class);
-        when(policy.getSubjectFeatureInstances()).thenReturn(sfi);
-
-        ClassifierInstance ci = mock(ClassifierInstance.class);
-        List<ClassifierInstance> ciList = Arrays.asList(ci);
-        when(sfi.getClassifierInstance()).thenReturn(ciList);
-        ClassifierName ciName = mock(ClassifierName.class);
-        when(ci.getName()).thenReturn(ciName);
-
-        ActionInstance ai = mock(ActionInstance.class);
-        List<ActionInstance> actionList = Arrays.asList(ai);
-        when(sfi.getActionInstance()).thenReturn(actionList);
-        ActionName actionName = mock(ActionName.class);
-        when(ai.getName()).thenReturn(actionName);
-
+    public void testConstructor() {
         IndexedTenant it = new IndexedTenant(tenant);
 
         assertEquals(tenant.hashCode(), it.hashCode());
         assertEquals(tenant, it.getTenant());
         assertEquals(eg, it.getEndpointGroup(egId));
         assertEquals(contract, it.getContract(contractId));
-        assertEquals(l3Context, it.getNetworkDomain(l3ContextId));
-        assertEquals(l2BridgeDomain, it.getNetworkDomain(l2BridgeDomainId));
-        assertEquals(l2FloodDomain, it.getNetworkDomain(l2FloodDomainId));
+        assertEquals(l3, it.getNetworkDomain(l3id));
+        assertEquals(bd, it.getNetworkDomain(bdid));
+        assertEquals(fd, it.getNetworkDomain(fdid));
         assertEquals(ci, it.getClassifier(ciName));
         assertEquals(ai, it.getAction(actionName));
     }
 
     @Test
-    public void constructorTestNullValues() {
-        when(fwCtx.getL3Context()).thenReturn(null);
-        when(fwCtx.getL2BridgeDomain()).thenReturn(null);
-        when(fwCtx.getL2FloodDomain()).thenReturn(null);
-        when(fwCtx.getSubnet()).thenReturn(null);
-
-        SubjectFeatureInstances sfi = mock(SubjectFeatureInstances.class);
-        when(policy.getSubjectFeatureInstances()).thenReturn(sfi);
-        when(sfi.getClassifierInstance()).thenReturn(null);
-        when(sfi.getActionInstance()).thenReturn(null);
+    public void testConstructor_NullValues() {
+        ForwardingContext fwCtx = new ForwardingContextBuilder().setL3Context(null)
+                .setL2BridgeDomain(null)
+                .setL2FloodDomain(null)
+                .setSubnet(null)
+                .build();
+        SubjectFeatureInstances sfi =
+                new SubjectFeatureInstancesBuilder().setClassifierInstance(null)
+                        .setActionInstance(null)
+                        .build();
+        Policy policy = new PolicyBuilder(this.policy).setSubjectFeatureInstances(sfi).build();
+        Tenant tenant = new TenantBuilder().setPolicy(policy).setForwardingContext(fwCtx).build();
 
         IndexedTenant it = new IndexedTenant(tenant);
+
         assertEquals(tenant.hashCode(), it.hashCode());
         assertEquals(tenant, it.getTenant());
     }
 
+    @Test
+    public void testResolveND() throws Exception {
+        SubnetId sid1 = new SubnetId("dd25397d-d829-4c8d-8c01-31f129b8de8f");
+        SubnetId sid2 = new SubnetId("c752ba40-40aa-4a47-8138-9b7175b854fa");
+        L3ContextId l3id = new L3ContextId("f2311f52-890f-4095-8b85-485ec8b92b3c");
+        L2BridgeDomainId bdid = new L2BridgeDomainId("70aeb9ea-4ca1-4fb9-9780-22b04b84a0d6");
+        L2FloodDomainId fdid = new L2FloodDomainId("252fbac6-bb6e-4d16-808d-6f56d20e5cca");
+
+        L3Context l3c = new L3ContextBuilder().setId(l3id).build();
+        L2BridgeDomain bd = new L2BridgeDomainBuilder().setParent(l3id).setId(bdid).build();
+        L2FloodDomain fd = new L2FloodDomainBuilder().setParent(bdid).setId(fdid).build();
+        Subnet subnet1 = new SubnetBuilder().setParent(fdid).setId(sid1).build();
+        Subnet subnet2 = new SubnetBuilder().setParent(bdid).setId(sid2).build();
+        Tenant tenant = new TenantBuilder()
+                .setForwardingContext(new ForwardingContextBuilder().setSubnet(ImmutableList.of(subnet1, subnet2))
+                        .setL2BridgeDomain(ImmutableList.of(bd))
+                        .setL3Context(ImmutableList.of(l3c))
+                        .setL2FloodDomain(ImmutableList.of(fd))
+                        .build())
+                .build();
+        IndexedTenant it = new IndexedTenant(tenant);
+
+        assertNotNull(it.getNetworkDomain(sid1));
+
+        Collection<Subnet> subnets = it.resolveSubnets(sid1);
+
+        assertTrue(subnets.contains(subnet1));
+        assertTrue(subnets.contains(subnet2));
+        assertEquals(l3id, it.resolveL3Context(sid1).getId());
+        assertEquals(bdid, it.resolveL2BridgeDomain(sid1).getId());
+        assertEquals(fdid, it.resolveL2FloodDomain(sid1).getId());
+    }
+
     @Test
     public void equalsTest() {
         Tenant tenant = mock(Tenant.class);
old mode 100644 (file)
new mode 100755 (executable)
index 0111601..55d7131
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -15,9 +15,10 @@ import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
-import java.util.HashSet;
 import java.util.List;
 
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
 import org.junit.Test;
 import org.opendaylight.groupbasedpolicy.util.InheritanceUtils;
 import org.opendaylight.groupbasedpolicy.util.TenantUtils;
@@ -98,240 +99,149 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.endpoint.group.ProviderTargetSelector;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.endpoint.group.ProviderTargetSelectorBuilder;
 
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
-
 public class InheritanceUtilsTest {
     // ******
     // Labels
     // ******
 
-    Quality q1 = new QualityBuilder()
-        .setName(new QualityName("q1"))
-        .build();
-    Quality q1Include = new QualityBuilder(q1)
-        .setInclusionRule(InclusionRule.Include)
-        .build();
-    Quality q1Exclude = new QualityBuilder(q1)
-        .setInclusionRule(InclusionRule.Exclude)
-        .build();
-    Quality q2 = new QualityBuilder()
-        .setName(new QualityName("q2"))
-        .build();
-    Quality q2Exclude = new QualityBuilder()
-        .setName(new QualityName("q2"))
-        .setInclusionRule(InclusionRule.Exclude)
-        .build();
-    Quality q3 = new QualityBuilder()
-        .setName(new QualityName("q3"))
-        .build();
-
-    Requirement r1 = new RequirementBuilder()
-        .setName(new RequirementName("r1"))
-        .build();
-    Requirement r2 = new RequirementBuilder()
-        .setName(new RequirementName("r2"))
-        .build();
-    Requirement r1exclude = new RequirementBuilder()
-        .setName(new RequirementName("r1"))
-        .setInclusionRule(InclusionRule.Exclude)
-        .build();
-    Requirement r3 = new RequirementBuilder()
-        .setName(new RequirementName("r3"))
-        .build();
-
-    Capability c1 = new CapabilityBuilder()
-        .setName(new CapabilityName("c1"))
-        .build();
-    Capability c2 = new CapabilityBuilder()
-        .setName(new CapabilityName("c2"))
-        .build();
-    Capability c1exclude = new CapabilityBuilder()
-        .setName(new CapabilityName("c1"))
-        .setInclusionRule(InclusionRule.Exclude)
-        .build();
-    Capability c3 = new CapabilityBuilder()
-        .setName(new CapabilityName("c3"))
-        .build();
-
-    Condition cond1 = new ConditionBuilder()
-        .setName(new ConditionName("cond1"))
-        .build();
-    Condition cond2 = new ConditionBuilder()
-        .setName(new ConditionName("cond2"))
-        .build();
-    Condition cond2exlude = new ConditionBuilder()
-        .setName(new ConditionName("cond2"))
-        .setInclusionRule(InclusionRule.Exclude)
-        .build();
+    Quality q1 = new QualityBuilder().setName(new QualityName("q1")).build();
+    Quality q1Include = new QualityBuilder(q1).setInclusionRule(InclusionRule.Include).build();
+    Quality q1Exclude = new QualityBuilder(q1).setInclusionRule(InclusionRule.Exclude).build();
+    Quality q2 = new QualityBuilder().setName(new QualityName("q2")).build();
+    Quality q2Exclude =
+            new QualityBuilder().setName(new QualityName("q2")).setInclusionRule(InclusionRule.Exclude).build();
+    Quality q3 = new QualityBuilder().setName(new QualityName("q3")).build();
+
+    Requirement r1 = new RequirementBuilder().setName(new RequirementName("r1")).build();
+    Requirement r2 = new RequirementBuilder().setName(new RequirementName("r2")).build();
+    Requirement r1exclude =
+            new RequirementBuilder().setName(new RequirementName("r1")).setInclusionRule(InclusionRule.Exclude).build();
+    Requirement r3 = new RequirementBuilder().setName(new RequirementName("r3")).build();
+
+    Capability c1 = new CapabilityBuilder().setName(new CapabilityName("c1")).build();
+    Capability c2 = new CapabilityBuilder().setName(new CapabilityName("c2")).build();
+    Capability c1exclude =
+            new CapabilityBuilder().setName(new CapabilityName("c1")).setInclusionRule(InclusionRule.Exclude).build();
+    Capability c3 = new CapabilityBuilder().setName(new CapabilityName("c3")).build();
+
+    Condition cond1 = new ConditionBuilder().setName(new ConditionName("cond1")).build();
+    Condition cond2 = new ConditionBuilder().setName(new ConditionName("cond2")).build();
+    Condition cond2exlude =
+            new ConditionBuilder().setName(new ConditionName("cond2")).setInclusionRule(InclusionRule.Exclude).build();
 
     // *********
     // Contracts
     // *********
 
     TargetName q2TargetName = new TargetName("q2");
-    Target q2Target = new TargetBuilder()
-        .setName(q2TargetName)
-        .setQuality(ImmutableList.of(q2))
-        .build();
+    Target q2Target = new TargetBuilder().setName(q2TargetName).setQuality(ImmutableList.of(q2)).build();
 
     TargetName q1ExcludeTargetName = new TargetName("q1_exclude");
-    Target q1ExcludeTarget = new TargetBuilder()
-        .setName(q1ExcludeTargetName)
-        .setQuality(ImmutableList.of(q1Exclude, q2))
-        .build();
+    Target q1ExcludeTarget =
+            new TargetBuilder().setName(q1ExcludeTargetName).setQuality(ImmutableList.of(q1Exclude, q2)).build();
 
     TargetName q1IncludeTargetName = new TargetName("q1_include");
-    Target q1IncludeTarget = new TargetBuilder()
-        .setName(q1IncludeTargetName)
-        .setQuality(ImmutableList.of(q1Include))
-        .build();
+    Target q1IncludeTarget =
+            new TargetBuilder().setName(q1IncludeTargetName).setQuality(ImmutableList.of(q1Include)).build();
 
-    Target q2PlusTarget = new TargetBuilder()
-        .setName(q2TargetName)
-        .setQuality(ImmutableList.of(q3))
-        .build();
+    Target q2PlusTarget = new TargetBuilder().setName(q2TargetName).setQuality(ImmutableList.of(q3)).build();
 
     SubjectName subject1 = new SubjectName("subject1");
     SubjectName subject2 = new SubjectName("subject2");
     SubjectName subject3 = new SubjectName("subject3");
 
-    RequirementMatcher rm_r1 = new RequirementMatcherBuilder()
-        .setName(new RequirementMatcherName("rm_r1"))
-        .setMatcherRequirement(ImmutableList.of(new MatcherRequirementBuilder(r1)
-                                                    .build()))
+    RequirementMatcher rm_r1 = new RequirementMatcherBuilder().setName(new RequirementMatcherName("rm_r1"))
+        .setMatcherRequirement(ImmutableList.of(new MatcherRequirementBuilder(r1).build()))
         .build();
-    RequirementMatcher rm_r1_plus = new RequirementMatcherBuilder()
-        .setName(new RequirementMatcherName("rm_r1"))
+    RequirementMatcher rm_r1_plus = new RequirementMatcherBuilder().setName(new RequirementMatcherName("rm_r1"))
         .setMatchType(MatchType.All)
-        .setMatcherRequirement(ImmutableList.of(new MatcherRequirementBuilder(r2)
-                                                    .build()))
+        .setMatcherRequirement(ImmutableList.of(new MatcherRequirementBuilder(r2).build()))
         .build();
 
-    CapabilityMatcher capm_c1 = new CapabilityMatcherBuilder()
-        .setName(new CapabilityMatcherName("capm_c1"))
-        .setMatcherCapability(ImmutableList.of(new MatcherCapabilityBuilder(c1)
-                                                .build()))
+    CapabilityMatcher capm_c1 = new CapabilityMatcherBuilder().setName(new CapabilityMatcherName("capm_c1"))
+        .setMatcherCapability(ImmutableList.of(new MatcherCapabilityBuilder(c1).build()))
         .build();
 
-    ConditionMatcher cm_c1 = new ConditionMatcherBuilder()
-        .setName(new ConditionMatcherName("cm_c1"))
+    ConditionMatcher cm_c1 = new ConditionMatcherBuilder().setName(new ConditionMatcherName("cm_c1"))
         .setCondition(ImmutableList.of(cond1))
         .build();
-    ConditionMatcher cm_c2 = new ConditionMatcherBuilder()
-        .setName(new ConditionMatcherName("cm_c2"))
+    ConditionMatcher cm_c2 = new ConditionMatcherBuilder().setName(new ConditionMatcherName("cm_c2"))
         .setMatchType(MatchType.All)
         .setCondition(ImmutableList.of(cond2))
         .build();
-    ConditionMatcher cm_c2_plus = new ConditionMatcherBuilder()
-        .setName(new ConditionMatcherName("cm_c2"))
+    ConditionMatcher cm_c2_plus = new ConditionMatcherBuilder().setName(new ConditionMatcherName("cm_c2"))
         .setCondition(ImmutableList.of(cond2exlude))
         .build();
 
     ClauseName clauseName1 = new ClauseName("clauseName1");
-    Clause clause1 = new ClauseBuilder()
-        .setName(clauseName1)
-        .setSubjectRefs(ImmutableList.of(subject1))
-        .setProviderMatchers(new ProviderMatchersBuilder()
-        .setGroupIdentificationConstraints(new GroupCapabilityConstraintCaseBuilder()
-            .setCapabilityMatcher(ImmutableList.of(capm_c1)).build())
-            .setConditionMatcher(ImmutableList.of(cm_c1))
-            .build())
-        .setConsumerMatchers(new ConsumerMatchersBuilder()
-        .setGroupIdentificationConstraints(new GroupRequirementConstraintCaseBuilder()
-            .setRequirementMatcher(ImmutableList.of(rm_r1)).build())
-            .setConditionMatcher(ImmutableList.of(cm_c2))
-            .build())
-        .build();
-
-    Clause clause1withConsMatcher = new ClauseBuilder()
-        .setName(clauseName1)
+    Clause clause1 =
+            new ClauseBuilder().setName(clauseName1)
+                .setSubjectRefs(ImmutableList.of(subject1))
+                .setProviderMatchers(new ProviderMatchersBuilder()
+                    .setGroupIdentificationConstraints(new GroupCapabilityConstraintCaseBuilder()
+                        .setCapabilityMatcher(ImmutableList.of(capm_c1)).build())
+                    .setConditionMatcher(ImmutableList.of(cm_c1))
+                    .build())
+                .setConsumerMatchers(new ConsumerMatchersBuilder()
+                    .setGroupIdentificationConstraints(new GroupRequirementConstraintCaseBuilder()
+                        .setRequirementMatcher(ImmutableList.of(rm_r1)).build())
+                    .setConditionMatcher(ImmutableList.of(cm_c2))
+                    .build())
+                .build();
+
+    Clause clause1withConsMatcher = new ClauseBuilder().setName(clauseName1)
         .setSubjectRefs(ImmutableList.of(subject2))
         .setConsumerMatchers(new ConsumerMatchersBuilder()
-        .setGroupIdentificationConstraints(new GroupRequirementConstraintCaseBuilder()
-            .setRequirementMatcher(ImmutableList.of(rm_r1_plus)).build())
+            .setGroupIdentificationConstraints(new GroupRequirementConstraintCaseBuilder()
+                .setRequirementMatcher(ImmutableList.of(rm_r1_plus)).build())
             .setConditionMatcher(ImmutableList.of(cm_c2_plus))
             .build())
         .build();
 
-    Clause clause1withProvMatcher = new ClauseBuilder()
-    .setName(clauseName1)
-    .setSubjectRefs(ImmutableList.of(subject3))
-    .setProviderMatchers(new ProviderMatchersBuilder()
-    .setGroupIdentificationConstraints(new GroupCapabilityConstraintCaseBuilder()
-        .setCapabilityMatcher(ImmutableList.of(capm_c1)).build())
-        .setConditionMatcher(ImmutableList.of(cm_c2_plus))
-        .build())
-    .build();
-
-    ActionRef a1 = new ActionRefBuilder()
-        .setName(new ActionName("a1"))
-        .build();
-    ClassifierRef cr1 = new ClassifierRefBuilder()
-        .setName(new ClassifierName("cr1"))
-        .build();
-    Rule rule1 = new RuleBuilder()
-        .setName(new RuleName("r1"))
+    Clause clause1withProvMatcher =
+            new ClauseBuilder().setName(clauseName1)
+                .setSubjectRefs(ImmutableList.of(subject3))
+                .setProviderMatchers(new ProviderMatchersBuilder()
+                    .setGroupIdentificationConstraints(new GroupCapabilityConstraintCaseBuilder()
+                        .setCapabilityMatcher(ImmutableList.of(capm_c1)).build())
+                    .setConditionMatcher(ImmutableList.of(cm_c2_plus))
+                    .build())
+                .build();
+
+    ActionRef a1 = new ActionRefBuilder().setName(new ActionName("a1")).build();
+    ClassifierRef cr1 = new ClassifierRefBuilder().setName(new ClassifierName("cr1")).build();
+    Rule rule1 = new RuleBuilder().setName(new RuleName("r1"))
         .setActionRef(ImmutableList.of(a1))
         .setClassifierRef(ImmutableList.of(cr1))
         .build();
-    Rule rule2 = new RuleBuilder()
-        .setName(new RuleName("r2"))
-        .setOrder(5)
-        .build();
-    Rule rule3 = new RuleBuilder()
-        .setName(new RuleName("r3"))
-        .setOrder(7)
-        .build();
-    Rule rule4 = new RuleBuilder()
-        .setName(new RuleName("r4"))
-        .setOrder(1)
-        .build();
+    Rule rule2 = new RuleBuilder().setName(new RuleName("r2")).setOrder(5).build();
+    Rule rule3 = new RuleBuilder().setName(new RuleName("r3")).setOrder(7).build();
+    Rule rule4 = new RuleBuilder().setName(new RuleName("r4")).setOrder(1).build();
 
-    Subject s1 = new SubjectBuilder()
-        .setName(new SubjectName("s1"))
-        .setRule(ImmutableList.of(rule1, rule2))
-        .build();
-    Subject s1_plus = new SubjectBuilder()
-        .setName(s1.getName())
-        .setRule(ImmutableList.of(rule3, rule4))
-        .setOrder(4)
-        .build();
-    Subject s2 = new SubjectBuilder()
-        .setName(new SubjectName("s2"))
-        .setOrder(5)
-        .build();
-    Subject s2_plus = new SubjectBuilder()
-    .setName(new SubjectName(s2.getName()))
-    .setOrder(6)
-    .build();
-
-    ContractId contractId1 = 
-            new ContractId("e7e6804f-7fcb-46cf-9bc6-abfec0896d95");
-    Contract contract1 = new ContractBuilder()
-        .setId(contractId1)
+    Subject s1 = new SubjectBuilder().setName(new SubjectName("s1")).setRule(ImmutableList.of(rule1, rule2)).build();
+    Subject s1_plus =
+            new SubjectBuilder().setName(s1.getName()).setRule(ImmutableList.of(rule3, rule4)).setOrder(4).build();
+    Subject s2 = new SubjectBuilder().setName(new SubjectName("s2")).setOrder(5).build();
+    Subject s2_plus = new SubjectBuilder().setName(new SubjectName(s2.getName())).setOrder(6).build();
+
+    ContractId contractId1 = new ContractId("e7e6804f-7fcb-46cf-9bc6-abfec0896d95");
+    Contract contract1 = new ContractBuilder().setId(contractId1)
         .setQuality(ImmutableList.of(q1))
-        .setTarget(ImmutableList.of(q2Target, 
-                                    q1IncludeTarget, 
-                                    q1ExcludeTarget))
+        .setTarget(ImmutableList.of(q2Target, q1IncludeTarget, q1ExcludeTarget))
         .setClause(ImmutableList.of(clause1))
         .setSubject(ImmutableList.of(s1))
         .build();
 
-    ContractId contractId2 = 
-            new ContractId("3f56ae44-d1e4-4617-95af-c809dfc50149");
-    Contract contract2 = new ContractBuilder()
-        .setId(contractId2)
+    ContractId contractId2 = new ContractId("3f56ae44-d1e4-4617-95af-c809dfc50149");
+    Contract contract2 = new ContractBuilder().setId(contractId2)
         .setParent(contractId1)
         .setTarget(ImmutableList.of(q2PlusTarget, q1IncludeTarget))
         .setClause(ImmutableList.of(clause1withConsMatcher))
         .setSubject(ImmutableList.of(s1_plus, s2))
         .build();
 
-    ContractId contractId3 = 
-            new ContractId("38d52ec1-301b-453a-88a6-3ffa777d7795");
-    Contract contract3 = new ContractBuilder()
-        .setId(contractId3)
+    ContractId contractId3 = new ContractId("38d52ec1-301b-453a-88a6-3ffa777d7795");
+    Contract contract3 = new ContractBuilder().setId(contractId3)
         .setParent(contractId1)
         .setTarget(ImmutableList.of(q2PlusTarget, q1IncludeTarget))
         .setClause(ImmutableList.of(clause1withProvMatcher))
@@ -339,24 +249,15 @@ public class InheritanceUtilsTest {
         .build();
 
     ContractId cloop2Id = new ContractId("89700928-7316-4216-a853-a7ea3934b8f4");
-    Contract cloop1 = new ContractBuilder()
-        .setId(new ContractId("56bbce36-e60b-473d-92de-bb63b5a6dbb5"))
+    Contract cloop1 = new ContractBuilder().setId(new ContractId("56bbce36-e60b-473d-92de-bb63b5a6dbb5"))
         .setParent(cloop2Id)
         .setClause(ImmutableList.of(clause1))
         .setSubject(ImmutableList.of(s1, s2))
         .build();
-    Contract cloop2 = new ContractBuilder()
-        .setId(cloop2Id)
-        .setParent(cloop1.getId())
-        .build();
-    ContractId cselfloopid = 
-            new ContractId("63edead2-d6f1-4acf-9f78-831595d194ee");
-    Contract cselfloop = new ContractBuilder()
-        .setId(cselfloopid)
-        .setParent(cselfloopid)
-        .build();
-    Contract corphan = new ContractBuilder()
-        .setId(new ContractId("f72c15f3-76ab-4c7e-a817-eb5f6efcb654"))
+    Contract cloop2 = new ContractBuilder().setId(cloop2Id).setParent(cloop1.getId()).build();
+    ContractId cselfloopid = new ContractId("63edead2-d6f1-4acf-9f78-831595d194ee");
+    Contract cselfloop = new ContractBuilder().setId(cselfloopid).setParent(cselfloopid).build();
+    Contract corphan = new ContractBuilder().setId(new ContractId("f72c15f3-76ab-4c7e-a817-eb5f6efcb654"))
         .setParent(new ContractId("eca4d0d5-8c62-4f46-ad42-71c1f4d3da12"))
         .build();
 
@@ -365,127 +266,95 @@ public class InheritanceUtilsTest {
     // ***************
 
     SelectorName cnsName1 = new SelectorName("cns1");
-    ConsumerNamedSelector cns1 = new ConsumerNamedSelectorBuilder()
-        .setName(cnsName1)
+    ConsumerNamedSelector cns1 = new ConsumerNamedSelectorBuilder().setName(cnsName1)
         .setContract(ImmutableList.of(contractId1))
         .setRequirement(ImmutableList.of(r2))
         .build();
 
-    ConsumerNamedSelector cns1_plus = new ConsumerNamedSelectorBuilder()
-        .setName(cnsName1)
+    ConsumerNamedSelector cns1_plus = new ConsumerNamedSelectorBuilder().setName(cnsName1)
         .setContract(ImmutableList.of(contractId2))
         .setRequirement(ImmutableList.of(r3))
         .build();
 
-    ProviderNamedSelector pns1 = new ProviderNamedSelectorBuilder()
-        .setName(cnsName1)
+    ProviderNamedSelector pns1 = new ProviderNamedSelectorBuilder().setName(cnsName1)
         .setContract(ImmutableList.of(contractId1))
         .setCapability(ImmutableList.of(c2))
         .build();
 
-    ProviderNamedSelector pns1_plus = new ProviderNamedSelectorBuilder()
-        .setName(cnsName1)
+    ProviderNamedSelector pns1_plus = new ProviderNamedSelectorBuilder().setName(cnsName1)
         .setContract(ImmutableList.of(contractId2))
         .setCapability(ImmutableList.of(c3))
         .build();
 
-    QualityMatcher qm_q1_all = new QualityMatcherBuilder()
-        .setName(new QualityMatcherName("qm_q1_all"))
-        .setMatcherQuality(ImmutableList.of(new MatcherQualityBuilder(q1)
-                                                .build()))
+    QualityMatcher qm_q1_all = new QualityMatcherBuilder().setName(new QualityMatcherName("qm_q1_all"))
+        .setMatcherQuality(ImmutableList.of(new MatcherQualityBuilder(q1).build()))
         .setMatchType(MatchType.All)
         .build();
-    QualityMatcher qm_q1_any = new QualityMatcherBuilder()
-        .setName(new QualityMatcherName("qm_q1_any"))
-        .setMatcherQuality(ImmutableList.of(new MatcherQualityBuilder(q1)
-                                            .build()))
+    QualityMatcher qm_q1_any = new QualityMatcherBuilder().setName(new QualityMatcherName("qm_q1_any"))
+        .setMatcherQuality(ImmutableList.of(new MatcherQualityBuilder(q1).build()))
         .setMatchType(MatchType.Any)
         .build();
-    QualityMatcher qm_q2q3_any = new QualityMatcherBuilder()
-        .setName(new QualityMatcherName("qm_q2q3_any"))
-        .setMatcherQuality(ImmutableList.of(new MatcherQualityBuilder(q2)
-                                                .build(),
-                                              new MatcherQualityBuilder(q3)
-                                                .build()))
+    QualityMatcher qm_q2q3_any = new QualityMatcherBuilder().setName(new QualityMatcherName("qm_q2q3_any"))
+        .setMatcherQuality(
+                ImmutableList.of(new MatcherQualityBuilder(q2).build(), new MatcherQualityBuilder(q3).build()))
         .setMatchType(MatchType.Any)
         .build();
 
-    QualityMatcher qm_q2tq2 = new QualityMatcherBuilder()
-        .setName(new QualityMatcherName("qm_q2tq2"))
-        .setMatcherQuality(ImmutableList.of(new MatcherQualityBuilder(q2)
-                                                .setTargetNamespace(q2TargetName)
-                                                .build()))
-        .setMatchType(MatchType.Any)
-        .build();
-    QualityMatcher qm_q2q3_plus = new QualityMatcherBuilder()
-        .setName(new QualityMatcherName("qm_q2q3_any"))
-        .setMatcherQuality(ImmutableList.of(new MatcherQualityBuilder(q3)
-                                                .setTargetNamespace(q2TargetName)
-                                                .build(),
-                                              new MatcherQualityBuilder(q2Exclude)
-                                                .build()))
-        .setMatchType(MatchType.All)
-        .build();
-    QualityMatcher qm_q1_plus = new QualityMatcherBuilder()
-        .setName(new QualityMatcherName("qm_q1_any"))
-        .build();
+    QualityMatcher qm_q2tq2 =
+            new QualityMatcherBuilder().setName(new QualityMatcherName("qm_q2tq2"))
+                .setMatcherQuality(
+                        ImmutableList.of(new MatcherQualityBuilder(q2).setTargetNamespace(q2TargetName).build()))
+                .setMatchType(MatchType.Any)
+                .build();
+    QualityMatcher qm_q2q3_plus =
+            new QualityMatcherBuilder().setName(new QualityMatcherName("qm_q2q3_any"))
+                .setMatcherQuality(
+                        ImmutableList.of(new MatcherQualityBuilder(q3).setTargetNamespace(q2TargetName).build(),
+                                new MatcherQualityBuilder(q2Exclude).build()))
+                .setMatchType(MatchType.All)
+                .build();
+    QualityMatcher qm_q1_plus = new QualityMatcherBuilder().setName(new QualityMatcherName("qm_q1_any")).build();
 
     SelectorName ctsName1 = new SelectorName("cts1");
-    ConsumerTargetSelector cts1 = new ConsumerTargetSelectorBuilder()
-        .setName(ctsName1)
+    ConsumerTargetSelector cts1 = new ConsumerTargetSelectorBuilder().setName(ctsName1)
         .setQualityMatcher(ImmutableList.of(qm_q1_all, qm_q1_any))
         .setRequirement(ImmutableList.of(r2))
         .build();
     SelectorName ctsName2 = new SelectorName("cts2");
-    ConsumerTargetSelector cts2 = new ConsumerTargetSelectorBuilder()
-        .setName(ctsName2)
+    ConsumerTargetSelector cts2 = new ConsumerTargetSelectorBuilder().setName(ctsName2)
         .setQualityMatcher(ImmutableList.of(qm_q2q3_any))
         .setRequirement(ImmutableList.of(r1exclude, r3))
         .build();
-    ConsumerTargetSelector cts1_plus = new ConsumerTargetSelectorBuilder()
-        .setName(ctsName1)
-        .setQualityMatcher(ImmutableList.of(qm_q1_plus,
-                                              qm_q2q3_any, 
-                                              qm_q1_plus))
+    ConsumerTargetSelector cts1_plus = new ConsumerTargetSelectorBuilder().setName(ctsName1)
+        .setQualityMatcher(ImmutableList.of(qm_q1_plus, qm_q2q3_any, qm_q1_plus))
         .setRequirement(ImmutableList.of(r3))
         .build();
-    ConsumerTargetSelector cts2_plus = new ConsumerTargetSelectorBuilder()
-        .setName(ctsName2)
-        .setQualityMatcher(ImmutableList.of(qm_q2tq2, 
-                                              qm_q2q3_plus))
+    ConsumerTargetSelector cts2_plus = new ConsumerTargetSelectorBuilder().setName(ctsName2)
+        .setQualityMatcher(ImmutableList.of(qm_q2tq2, qm_q2q3_plus))
         .setRequirement(ImmutableList.of(r3))
         .build();
 
     SelectorName ptsName1 = new SelectorName("pts1");
-    ProviderTargetSelector pts1 = new ProviderTargetSelectorBuilder()
-        .setName(ptsName1)
+    ProviderTargetSelector pts1 = new ProviderTargetSelectorBuilder().setName(ptsName1)
         .setQualityMatcher(ImmutableList.of(qm_q1_all, qm_q1_any))
         .setCapability(ImmutableList.of(c2))
         .build();
     SelectorName ptsName2 = new SelectorName("pts2");
-    ProviderTargetSelector pts2 = new ProviderTargetSelectorBuilder()
-        .setName(ptsName2)
+    ProviderTargetSelector pts2 = new ProviderTargetSelectorBuilder().setName(ptsName2)
         .setQualityMatcher(ImmutableList.of(qm_q2q3_any))
         .setCapability(ImmutableList.of(c1exclude, c3))
         .build();
-    ProviderTargetSelector pts1_plus = new ProviderTargetSelectorBuilder()
-        .setName(ptsName1)
-        .setQualityMatcher(ImmutableList.of(qm_q1_plus,
-                                              qm_q2q3_any, 
-                                              qm_q1_plus))
+    ProviderTargetSelector pts1_plus = new ProviderTargetSelectorBuilder().setName(ptsName1)
+        .setQualityMatcher(ImmutableList.of(qm_q1_plus, qm_q2q3_any, qm_q1_plus))
         .setCapability(ImmutableList.of(c3))
         .build();
-    ProviderTargetSelector pts2_plus = new ProviderTargetSelectorBuilder()
-        .setName(ptsName2)
-        .setQualityMatcher(ImmutableList.of(qm_q2tq2, 
-                                              qm_q2q3_plus))
+    ProviderTargetSelector pts2_plus = new ProviderTargetSelectorBuilder().setName(ptsName2)
+        .setQualityMatcher(ImmutableList.of(qm_q2tq2, qm_q2q3_plus))
         .setCapability(ImmutableList.of(c3))
         .build();
 
-    EndpointGroupId egId1 = 
-            new EndpointGroupId("c0e5edfb-02d2-412b-8757-a77b3daeb5d4");
-    EndpointGroup eg1 = new EndpointGroupBuilder()
-        .setId(egId1)
+    EndpointGroupId egId1 = new EndpointGroupId("c0e5edfb-02d2-412b-8757-a77b3daeb5d4");
+    EndpointGroup eg1 = new EndpointGroupBuilder().setId(egId1)
         .setRequirement(ImmutableList.of(r1))
         .setCapability(ImmutableList.of(c1))
         .setConsumerTargetSelector(ImmutableList.of(cts1, cts2))
@@ -493,10 +362,8 @@ public class InheritanceUtilsTest {
         .setProviderTargetSelector(ImmutableList.of(pts1, pts2))
         .setProviderNamedSelector(ImmutableList.of(pns1))
         .build();
-    EndpointGroupId egId2 = 
-            new EndpointGroupId("60483327-ad76-43dd-b3bf-54ffb73ef4b8"); 
-    EndpointGroup eg2 = new EndpointGroupBuilder()
-        .setId(egId2)
+    EndpointGroupId egId2 = new EndpointGroupId("60483327-ad76-43dd-b3bf-54ffb73ef4b8");
+    EndpointGroup eg2 = new EndpointGroupBuilder().setId(egId2)
         .setParent(egId1)
         .setConsumerTargetSelector(ImmutableList.of(cts1_plus, cts2_plus))
         .setConsumerNamedSelector(ImmutableList.of(cns1_plus))
@@ -504,8 +371,7 @@ public class InheritanceUtilsTest {
         .setProviderNamedSelector(ImmutableList.of(pns1_plus))
         .build();
 
-    EndpointGroupId egloop2Id = 
-            new EndpointGroupId("cb5be574-9836-4053-8ec4-4b4a43331d65");
+    EndpointGroupId egloop2Id = new EndpointGroupId("cb5be574-9836-4053-8ec4-4b4a43331d65");
     EndpointGroup egloop1 = new EndpointGroupBuilder()
         .setId(new EndpointGroupId("a33fdd4d-f58b-4741-a69f-08aecab9af2e"))
         .setParent(egloop2Id)
@@ -514,20 +380,13 @@ public class InheritanceUtilsTest {
         .setConsumerTargetSelector(ImmutableList.of(cts1))
         .setProviderTargetSelector(ImmutableList.of(pts1))
         .build();
-    EndpointGroup egloop2 = new EndpointGroupBuilder()
-        .setId(egloop2Id)
-        .setParent(egloop1.getId())
-        .build();
-    EndpointGroupId egselfloopid = 
-            new EndpointGroupId("996ad104-f852-4d77-96cf-cddde5cebb84");
-    EndpointGroup egselfloop = new EndpointGroupBuilder()
-        .setId(egselfloopid)
-        .setParent(egselfloopid)
-        .build();
-    EndpointGroup egorphan = new EndpointGroupBuilder()
-        .setId(new EndpointGroupId("feafeac9-ce1a-4b19-8455-8fcc9a4ff013"))
-        .setParent(new EndpointGroupId("aa9dfcf1-610c-42f9-8c3a-f67b43196821"))
-        .build();
+    EndpointGroup egloop2 = new EndpointGroupBuilder().setId(egloop2Id).setParent(egloop1.getId()).build();
+    EndpointGroupId egselfloopid = new EndpointGroupId("996ad104-f852-4d77-96cf-cddde5cebb84");
+    EndpointGroup egselfloop = new EndpointGroupBuilder().setId(egselfloopid).setParent(egselfloopid).build();
+    EndpointGroup egorphan =
+            new EndpointGroupBuilder().setId(new EndpointGroupId("feafeac9-ce1a-4b19-8455-8fcc9a4ff013"))
+                .setParent(new EndpointGroupId("aa9dfcf1-610c-42f9-8c3a-f67b43196821"))
+                .build();
 
     // *******
     // Tenants
@@ -550,8 +409,7 @@ public class InheritanceUtilsTest {
     // Other test state
     // ****************
 
-    public boolean containsQuality(List<? extends QualityBase> qualities, 
-                                   QualityBase quality) {
+    public boolean containsQuality(List<? extends QualityBase> qualities, QualityBase quality) {
         for (QualityBase q : qualities) {
             if (q.getName().equals(quality.getName()))
                 return true;
@@ -564,30 +422,29 @@ public class InheritanceUtilsTest {
         Tenant tenant = InheritanceUtils.resolveTenant(tenant1);
         Contract c1 = TenantUtils.findContract(tenant, contractId1);
 
-        // target with a quality directly in the target and one in 
+        // target with a quality directly in the target and one in
         // the containing contract
         Target result = TenantUtils.findTarget(c1, q2TargetName);
+
+        assertNotNull(result);
         assertEquals(q2TargetName, result.getName());
         List<Quality> qualities = result.getQuality();
-        assertTrue(q1.getName() + " found in q2target", 
-                   containsQuality(qualities, q1));
-        assertTrue(q2.getName() + " found in q2target", 
-                   containsQuality(qualities, q2));
+        assertTrue(containsQuality(qualities, q1));
+        assertTrue(containsQuality(qualities, q2));
 
         // target with a quality directly in the target with explicit "include"
         result = TenantUtils.findTarget(c1, q1IncludeTargetName);
+        assertNotNull(result);
         qualities = result.getQuality();
-        assertTrue(q1.getName() + " found in q1IncludeTargetName", 
-                   containsQuality(qualities, q1));
+        assertTrue(containsQuality(qualities, q1));
 
         // target with a quality from the containing contract but overridden
         // in the target
         result = TenantUtils.findTarget(c1, q1ExcludeTargetName);
+        assertNotNull(result);
         qualities = result.getQuality();
-        assertFalse(q1.getName() + " found in q1ExcludeTargetName", 
-                    containsQuality(qualities, q1));
-        assertTrue(q2.getName() + " found in q1ExcludeTargetName", 
-                   containsQuality(qualities, q2));
+        assertFalse(containsQuality(qualities, q1));
+        assertTrue(containsQuality(qualities, q2));
     }
 
     @Test
@@ -598,38 +455,31 @@ public class InheritanceUtilsTest {
         // hits the q2PlusTarget which should include everything in q2Target
         // plus q3
         Target result = TenantUtils.findTarget(c2, q2TargetName);
+        assertNotNull(result);
         List<Quality> qualities = result.getQuality();
-        assertTrue(q1.getName() + " found in q2target", 
-                   containsQuality(qualities, q1));
-        assertTrue(q2.getName() + " found in q2target", 
-                   containsQuality(qualities, q2));
-        assertTrue(q3.getName() + " found in q2target", 
-                   containsQuality(qualities, q3));
+        assertTrue(containsQuality(qualities, q1));
+        assertTrue(containsQuality(qualities, q2));
+        assertTrue(containsQuality(qualities, q3));
 
         // Simple case of inheriting the behavior from the base but not messing
         // it up
         result = TenantUtils.findTarget(c2, q1IncludeTargetName);
+        assertNotNull(result);
         qualities = result.getQuality();
-        assertTrue(q1.getName() + " found in q1IncludeTargetName", 
-                   containsQuality(qualities, q1));
-        assertFalse(q2.getName() + " found in q1IncludeTargetName", 
-                   containsQuality(qualities, q2));
-        assertFalse(q3.getName() + " found in q1IncludeTargetName", 
-                    containsQuality(qualities, q3));
+        assertTrue(containsQuality(qualities, q1));
+        assertFalse(containsQuality(qualities, q2));
+        assertFalse(containsQuality(qualities, q3));
 
         // Inherit a target from the base that isn't found in the child at all
         result = TenantUtils.findTarget(c2, q1ExcludeTargetName);
+        assertNotNull(result);
         qualities = result.getQuality();
-        assertFalse(q1.getName() + " found in q1ExcludeTargetName", 
-                    containsQuality(qualities, q1));
-        assertTrue(q2.getName() + " found in q1ExcludeTargetName", 
-                   containsQuality(qualities, q2));
-        assertFalse(q3.getName() + " found in q1ExcludeTargetName", 
-                    containsQuality(qualities, q3));
+        assertFalse(containsQuality(qualities, q1));
+        assertTrue(containsQuality(qualities, q2));
+        assertFalse(containsQuality(qualities, q3));
     }
 
-    private boolean containsRequirement(List<? extends RequirementBase> requirements, 
-                                       RequirementBase requirement) {
+    private boolean containsRequirement(List<? extends RequirementBase> requirements, RequirementBase requirement) {
         for (RequirementBase r : requirements) {
             if (r.getName().equals(requirement.getName()))
                 return true;
@@ -637,8 +487,7 @@ public class InheritanceUtilsTest {
         return false;
     }
 
-    private boolean containsCapability(List<? extends CapabilityBase> capabilities, 
-                                      CapabilityBase capability) {
+    private boolean containsCapability(List<? extends CapabilityBase> capabilities, CapabilityBase capability) {
         for (CapabilityBase r : capabilities) {
             if (r.getName().equals(capability.getName()))
                 return true;
@@ -646,8 +495,7 @@ public class InheritanceUtilsTest {
         return false;
     }
 
-    private boolean containsCondition(List<? extends Condition> conditions, 
-                                      Condition condition) {
+    private boolean containsCondition(List<? extends Condition> conditions, Condition condition) {
         for (Condition r : conditions) {
             if (r.getName().equals(condition.getName()))
                 return true;
@@ -661,21 +509,19 @@ public class InheritanceUtilsTest {
         EndpointGroup egResult1 = TenantUtils.findEndpointGroup(tenant, egId1);
 
         // should get r1 from eg1 and r2 from target selector
-        ConsumerTargetSelector result =
-                TenantUtils.findCts(egResult1, ctsName1);
+        ConsumerTargetSelector result = TenantUtils.findCts(egResult1, ctsName1);
+        assertNotNull(result);
         assertEquals(ctsName1, result.getName());
         List<Requirement> requirements = result.getRequirement();
-        assertTrue(r1.getName() + " found in " + requirements,
-                   containsRequirement(requirements, r1));
-        assertTrue(r2.getName() + " found in " + requirements,
-                   containsRequirement(requirements, r2));
+        assertTrue(containsRequirement(requirements, r1));
+        assertTrue(containsRequirement(requirements, r2));
 
         List<QualityMatcher> matchers = result.getQualityMatcher();
         assertEquals(2, matchers.size());
         for (QualityMatcher m : matchers) {
             if (m.getName().equals(new QualityMatcherName("qm_q1_all"))) {
                 assertTrue(containsQuality(m.getMatcherQuality(), q1));
-                assertEquals(MatchType.All, m.getMatchType());                
+                assertEquals(MatchType.All, m.getMatchType());
             } else {
                 assertTrue(containsQuality(m.getMatcherQuality(), q1));
                 assertEquals(MatchType.Any, m.getMatchType());
@@ -685,14 +531,12 @@ public class InheritanceUtilsTest {
         // should get r1 from eg1 but excluded in target selector
         // r3 comes from target selector
         result = TenantUtils.findCts(egResult1, ctsName2);
+        assertNotNull(result);
         assertEquals(ctsName2, result.getName());
         requirements = result.getRequirement();
-        assertFalse(r1.getName() + " found in " + requirements,
-                   containsRequirement(requirements, r1));
-        assertFalse(r2.getName() + " found in " + requirements,
-                   containsRequirement(requirements, r2));
-        assertTrue(r3.getName() + " found in " + requirements,
-                   containsRequirement(requirements, r3));
+        assertFalse(containsRequirement(requirements, r1));
+        assertFalse(containsRequirement(requirements, r2));
+        assertTrue(containsRequirement(requirements, r3));
 
         matchers = result.getQualityMatcher();
         assertEquals(1, matchers.size());
@@ -706,19 +550,17 @@ public class InheritanceUtilsTest {
         Tenant tenant = InheritanceUtils.resolveTenant(tenant1);
         EndpointGroup egResult2 = TenantUtils.findEndpointGroup(tenant, egId2);
 
-        ConsumerTargetSelector result = 
-                TenantUtils.findCts(egResult2, ctsName1);
+        ConsumerTargetSelector result = TenantUtils.findCts(egResult2, ctsName1);
 
+        assertNotNull(result);
         List<Requirement> requirements = result.getRequirement();
-        assertTrue(r1.getName() + " found in " + requirements,
-                   containsRequirement(requirements, r1));
-        assertTrue(r3.getName() + " found in " + requirements,
-                   containsRequirement(requirements, r3));
+        assertTrue(containsRequirement(requirements, r1));
+        assertTrue(containsRequirement(requirements, r3));
 
-        // should have three matchers, 
+        // should have three matchers,
         // (1) qm_q1_all inherited from endpoint group 1
-        // (2) qm_q1_any inherited from endpoint group 1, but overridden in 
-        //     endpoint group 2 with no new semantics
+        // (2) qm_q1_any inherited from endpoint group 1, but overridden in
+        // endpoint group 2 with no new semantics
         // (3) qm_q2q3_any defined in endpoint group 2
         List<QualityMatcher> matchers = result.getQualityMatcher();
         assertEquals(3, matchers.size());
@@ -739,21 +581,19 @@ public class InheritanceUtilsTest {
         }
 
         result = TenantUtils.findCts(egResult2, ctsName2);
+        assertNotNull(result);
         assertEquals(ctsName2, result.getName());
         requirements = result.getRequirement();
 
         // should get r1 from eg1 but excluded in target selector
         // r3 comes from target selector
-        assertFalse(r1.getName() + " found in " + requirements,
-                   containsRequirement(requirements, r1));
-        assertFalse(r2.getName() + " found in " + requirements,
-                   containsRequirement(requirements, r2));
-        assertTrue(r3.getName() + " found in " + requirements,
-                   containsRequirement(requirements, r3));
-
-        // Should get 2 matchers: 
-        // (1) qm_q2q2_any inherited from eg1, except that q2 is excluded 
-        //     by qm_q2q3_plus and q3 has a target namespace added 
+        assertFalse(containsRequirement(requirements, r1));
+        assertFalse(containsRequirement(requirements, r2));
+        assertTrue(containsRequirement(requirements, r3));
+
+        // Should get 2 matchers:
+        // (1) qm_q2q2_any inherited from eg1, except that q2 is excluded
+        // by qm_q2q3_plus and q3 has a target namespace added
         // (2) qm_q2tq2_any newly-defined with a target namespace
         matchers = result.getQualityMatcher();
         assertEquals(2, matchers.size());
@@ -774,8 +614,7 @@ public class InheritanceUtilsTest {
                 assertTrue(containsQuality(m.getMatcherQuality(), q2));
                 assertEquals(MatchType.Any, m.getMatchType());
                 assertEquals(1, m.getMatcherQuality().size());
-                assertEquals(q2TargetName,
-                             m.getMatcherQuality().get(0).getTargetNamespace());
+                assertEquals(q2TargetName, m.getMatcherQuality().get(0).getTargetNamespace());
             }
         }
     }
@@ -786,20 +625,15 @@ public class InheritanceUtilsTest {
         EndpointGroup egResult1 = TenantUtils.findEndpointGroup(tenant, egId1);
 
         // should get r1 from eg1 and r2 from selector
-        ConsumerNamedSelector result =
-                TenantUtils.findCns(egResult1, cnsName1);
+        ConsumerNamedSelector result = TenantUtils.findCns(egResult1, cnsName1);
+        assertNotNull(result);
         assertEquals(cnsName1, result.getName());
         List<Requirement> requirements = result.getRequirement();
         assertEquals(2, requirements.size());
-        assertTrue(r1.getName() + " found in " + requirements,
-                   containsRequirement(requirements, r1));
-        assertTrue(r2.getName() + " found in " + requirements,
-                   containsRequirement(requirements, r2));
-
+        assertTrue(containsRequirement(requirements, r1));
+        assertTrue(containsRequirement(requirements, r2));
         assertEquals(1, result.getContract().size());
-        HashSet<ContractId> cids = new HashSet<>();
-        cids.addAll(result.getContract());
-        assertEquals(ImmutableSet.of(contractId1), cids);
+        assertTrue(result.getContract().contains(contractId1));
     }
 
     @Test
@@ -807,24 +641,19 @@ public class InheritanceUtilsTest {
         Tenant tenant = InheritanceUtils.resolveTenant(tenant1);
         EndpointGroup egResult2 = TenantUtils.findEndpointGroup(tenant, egId2);
 
-        // should get r1 from eg1 and r2 from eg1 selector, 
+        // should get r1 from eg1 and r2 from eg1 selector,
         // and r3 from eg2 selector
-        ConsumerNamedSelector result =
-                TenantUtils.findCns(egResult2, cnsName1);
+        ConsumerNamedSelector result = TenantUtils.findCns(egResult2, cnsName1);
+        assertNotNull(result);
         assertEquals(cnsName1, result.getName());
         List<Requirement> requirements = result.getRequirement();
         assertEquals(3, requirements.size());
-        assertTrue(r1.getName() + " found in " + requirements,
-                   containsRequirement(requirements, r1));
-        assertTrue(r2.getName() + " found in " + requirements,
-                   containsRequirement(requirements, r2));
-        assertTrue(r3.getName() + " found in " + requirements,
-                   containsRequirement(requirements, r3));
+        assertTrue(containsRequirement(requirements, r1));
+        assertTrue(containsRequirement(requirements, r2));
+        assertTrue(containsRequirement(requirements, r3));
 
         assertEquals(2, result.getContract().size());
-        HashSet<ContractId> cids = new HashSet<>();
-        cids.addAll(result.getContract());
-        assertEquals(ImmutableSet.of(contractId1, contractId2), cids);
+        assertTrue(result.getContract().containsAll(ImmutableSet.of(contractId1, contractId2)));
     }
 
     @Test
@@ -833,21 +662,19 @@ public class InheritanceUtilsTest {
         EndpointGroup egResult1 = TenantUtils.findEndpointGroup(tenant, egId1);
 
         // should get c1 from eg1 and c2 from target selector
-        ProviderTargetSelector result =
-                TenantUtils.findPts(egResult1, ptsName1);
+        ProviderTargetSelector result = TenantUtils.findPts(egResult1, ptsName1);
+        assertNotNull(result);
         assertEquals(ptsName1, result.getName());
         List<Capability> capabilities = result.getCapability();
-        assertTrue(c1.getName() + " found in " + capabilities,
-                   containsCapability(capabilities, c1));
-        assertTrue(c2.getName() + " found in " + capabilities,
-                   containsCapability(capabilities, c2));
+        assertTrue(containsCapability(capabilities, c1));
+        assertTrue(containsCapability(capabilities, c2));
 
         List<QualityMatcher> matchers = result.getQualityMatcher();
         assertEquals(2, matchers.size());
         for (QualityMatcher m : matchers) {
             if (m.getName().equals(new QualityMatcherName("qm_q1_all"))) {
                 assertTrue(containsQuality(m.getMatcherQuality(), q1));
-                assertEquals(MatchType.All, m.getMatchType());                
+                assertEquals(MatchType.All, m.getMatchType());
             } else {
                 assertTrue(containsQuality(m.getMatcherQuality(), q1));
                 assertEquals(MatchType.Any, m.getMatchType());
@@ -857,14 +684,12 @@ public class InheritanceUtilsTest {
         // should get c1 from eg1 but excluded in target selector
         // c3 comes from target selector
         result = TenantUtils.findPts(egResult1, ptsName2);
+        assertNotNull(result);
         assertEquals(ptsName2, result.getName());
         capabilities = result.getCapability();
-        assertFalse(c1.getName() + " found in " + capabilities,
-                   containsCapability(capabilities, c1));
-        assertFalse(c2.getName() + " found in " + capabilities,
-                   containsCapability(capabilities, c2));
-        assertTrue(c3.getName() + " found in " + capabilities,
-                   containsCapability(capabilities, c3));
+        assertFalse(containsCapability(capabilities, c1));
+        assertFalse(containsCapability(capabilities, c2));
+        assertTrue(containsCapability(capabilities, c3));
 
         matchers = result.getQualityMatcher();
         assertEquals(1, matchers.size());
@@ -878,19 +703,17 @@ public class InheritanceUtilsTest {
         Tenant tenant = InheritanceUtils.resolveTenant(tenant1);
         EndpointGroup egResult2 = TenantUtils.findEndpointGroup(tenant, egId2);
 
-        ProviderTargetSelector result = 
-                TenantUtils.findPts(egResult2, ptsName1);
+        ProviderTargetSelector result = TenantUtils.findPts(egResult2, ptsName1);
 
+        assertNotNull(result);
         List<Capability> capabilities = result.getCapability();
-        assertTrue(c1.getName() + " found in " + capabilities,
-                   containsCapability(capabilities, c1));
-        assertTrue(c3.getName() + " found in " + capabilities,
-                   containsCapability(capabilities, c3));
+        assertTrue(containsCapability(capabilities, c1));
+        assertTrue(containsCapability(capabilities, c3));
 
-        // should have three matchers, 
+        // should have three matchers,
         // (1) qm_q1_all inherited from endpoint group 1
-        // (2) qm_q1_any inherited from endpoint group 1, but overridden in 
-        //     endpoint group 2 with no new semantics
+        // (2) qm_q1_any inherited from endpoint group 1, but overridden in
+        // endpoint group 2 with no new semantics
         // (3) qm_q2q3_any defined in endpoint group 2
         List<QualityMatcher> matchers = result.getQualityMatcher();
         assertEquals(3, matchers.size());
@@ -911,21 +734,19 @@ public class InheritanceUtilsTest {
         }
 
         result = TenantUtils.findPts(egResult2, ptsName2);
+        assertNotNull(result);
         assertEquals(ptsName2, result.getName());
         capabilities = result.getCapability();
 
         // should get c1 from eg1 but excluded in target selector
         // c3 comes from target selector
-        assertFalse(c1.getName() + " found in " + capabilities,
-                   containsCapability(capabilities, c1));
-        assertFalse(c2.getName() + " found in " + capabilities,
-                   containsCapability(capabilities, c2));
-        assertTrue(c3.getName() + " found in " + capabilities,
-                   containsCapability(capabilities, c3));
-
-        // Should get 2 matchers: 
-        // (1) qm_q2q2_any inherited from eg1, except that q2 is excluded 
-        //     by qm_q2q3_plus and q3 has a target namespace added 
+        assertFalse(containsCapability(capabilities, c1));
+        assertFalse(containsCapability(capabilities, c2));
+        assertTrue(containsCapability(capabilities, c3));
+
+        // Should get 2 matchers:
+        // (1) qm_q2q2_any inherited from eg1, except that q2 is excluded
+        // by qm_q2q3_plus and q3 has a target namespace added
         // (2) qm_q2tq2_any newly-defined with a target namespace
         matchers = result.getQualityMatcher();
         assertEquals(2, matchers.size());
@@ -946,8 +767,7 @@ public class InheritanceUtilsTest {
                 assertTrue(containsQuality(m.getMatcherQuality(), q2));
                 assertEquals(MatchType.Any, m.getMatchType());
                 assertEquals(1, m.getMatcherQuality().size());
-                assertEquals(q2TargetName,
-                             m.getMatcherQuality().get(0).getTargetNamespace());
+                assertEquals(q2TargetName, m.getMatcherQuality().get(0).getTargetNamespace());
             }
         }
     }
@@ -956,22 +776,18 @@ public class InheritanceUtilsTest {
     public void testProviderNamedSelectorSimple() throws Exception {
         Tenant tenant = InheritanceUtils.resolveTenant(tenant1);
         EndpointGroup egResult1 = TenantUtils.findEndpointGroup(tenant, egId1);
-        
+
         // should get c1 from eg1 and c2 from selector
-        ProviderNamedSelector result =
-                TenantUtils.findPns(egResult1, cnsName1);
+        ProviderNamedSelector result = TenantUtils.findPns(egResult1, cnsName1);
+        assertNotNull(result);
         assertEquals(cnsName1, result.getName());
         List<Capability> capabilities = result.getCapability();
         assertEquals(2, capabilities.size());
-        assertTrue(c1.getName() + " found in " + capabilities,
-                   containsCapability(capabilities, c1));
-        assertTrue(c2.getName() + " found in " + capabilities,
-                   containsCapability(capabilities, c2));
+        assertTrue(containsCapability(capabilities, c1));
+        assertTrue(containsCapability(capabilities, c2));
 
         assertEquals(1, result.getContract().size());
-        HashSet<ContractId> cids = new HashSet<>();
-        cids.addAll(result.getContract());
-        assertEquals(ImmutableSet.of(contractId1), cids);
+        assertTrue(result.getContract().contains(contractId1));
     }
 
     @Test
@@ -979,65 +795,60 @@ public class InheritanceUtilsTest {
         Tenant tenant = InheritanceUtils.resolveTenant(tenant1);
         EndpointGroup egResult2 = TenantUtils.findEndpointGroup(tenant, egId2);
 
-        // should get c1 from eg1 and c2 from eg1 selector, 
+        // should get c1 from eg1 and c2 from eg1 selector,
         // and c3 from eg2 selector
-        ProviderNamedSelector result =
-                TenantUtils.findPns(egResult2, cnsName1);
+        ProviderNamedSelector result = TenantUtils.findPns(egResult2, cnsName1);
+        assertNotNull(result);
         assertEquals(cnsName1, result.getName());
         List<Capability> capabilities = result.getCapability();
         assertEquals(3, capabilities.size());
-        assertTrue(c1.getName() + " found in " + capabilities,
-                   containsCapability(capabilities, c1));
-        assertTrue(c2.getName() + " found in " + capabilities,
-                   containsCapability(capabilities, c2));
-        assertTrue(c3.getName() + " found in " + capabilities,
-                   containsCapability(capabilities, c3));
+        assertTrue(containsCapability(capabilities, c1));
+        assertTrue(containsCapability(capabilities, c2));
+        assertTrue(containsCapability(capabilities, c3));
 
         assertEquals(2, result.getContract().size());
-        HashSet<ContractId> cids = new HashSet<>();
-        cids.addAll(result.getContract());
-        assertEquals(ImmutableSet.of(contractId1, contractId2), cids);
+        assertTrue(result.getContract().containsAll(ImmutableSet.of(contractId1, contractId2)));
     }
 
     @Test
     public void testClauseSimple() throws Exception {
         Tenant tenant = InheritanceUtils.resolveTenant(tenant1);
         Contract cresult1 = TenantUtils.findContract(tenant, contractId1);
-        
+
         Clause result = TenantUtils.findClause(cresult1, clauseName1);
+        assertNotNull(result);
         assertEquals(clauseName1, result.getName());
 
         // subject refs: subject1 from clause1
         assertEquals(1, result.getSubjectRefs().size());
-        assertEquals(ImmutableSet.of(subject1), 
-                     ImmutableSet.copyOf(result.getSubjectRefs()));
+        assertEquals(ImmutableSet.of(subject1), ImmutableSet.copyOf(result.getSubjectRefs()));
 
         assertNotNull(result.getProviderMatchers());
-        List<ConditionMatcher> cm = 
-                result.getProviderMatchers().getConditionMatcher();
+        List<ConditionMatcher> cm = result.getProviderMatchers().getConditionMatcher();
         assertEquals(1, cm.size());
         assertEquals(1, cm.get(0).getCondition().size());
         assertTrue(containsCondition(cm.get(0).getCondition(), cond1));
 
-        
-        List<CapabilityMatcher> capm = 
-                ((GroupCapabilityConstraintCase)result.getProviderMatchers().getGroupIdentificationConstraints()).getCapabilityMatcher();
+        List<CapabilityMatcher> capm =
+                ((GroupCapabilityConstraintCase) result.getProviderMatchers().getGroupIdentificationConstraints())
+                    .getCapabilityMatcher();
         assertEquals(1, capm.size());
         assertEquals(1, capm.get(0).getMatcherCapability().size());
         assertTrue(containsCapability(capm.get(0).getMatcherCapability(), c1));
-        
+
         assertNotNull(result.getConsumerMatchers());
         cm = result.getConsumerMatchers().getConditionMatcher();
         assertEquals(1, cm.size());
         assertEquals(1, cm.get(0).getCondition().size());
         assertTrue(containsCondition(cm.get(0).getCondition(), cond2));
 
-        List<RequirementMatcher> pm = 
-                ((GroupRequirementConstraintCase)result.getConsumerMatchers().getGroupIdentificationConstraints()).getRequirementMatcher();
+        List<RequirementMatcher> pm =
+                ((GroupRequirementConstraintCase) result.getConsumerMatchers().getGroupIdentificationConstraints())
+                    .getRequirementMatcher();
         assertEquals(1, pm.size());
         assertEquals(1, pm.get(0).getMatcherRequirement().size());
         assertTrue(containsRequirement(pm.get(0).getMatcherRequirement(), r1));
-        
+
     }
 
     @Test
@@ -1046,22 +857,22 @@ public class InheritanceUtilsTest {
         Contract cresult2 = TenantUtils.findContract(tenant, contractId2);
 
         Clause result = TenantUtils.findClause(cresult2, clauseName1);
+        assertNotNull(result);
         assertEquals(clauseName1, result.getName());
+
         // subject refs: subject1 from clause1, subject2 from clause2
         assertEquals(2, result.getSubjectRefs().size());
-        assertEquals(ImmutableSet.of(subject1, subject2), 
-                     ImmutableSet.copyOf(result.getSubjectRefs()));
+        assertEquals(ImmutableSet.of(subject1, subject2), ImmutableSet.copyOf(result.getSubjectRefs()));
 
         assertNotNull(result.getProviderMatchers());
-        List<ConditionMatcher> cm = 
-                result.getProviderMatchers().getConditionMatcher();
+        List<ConditionMatcher> cm = result.getProviderMatchers().getConditionMatcher();
         assertEquals(1, cm.size());
         assertEquals(1, cm.get(0).getCondition().size());
         assertTrue(containsCondition(cm.get(0).getCondition(), cond1));
 
-        List<CapabilityMatcher> capm = 
-                ((GroupCapabilityConstraintCase)result.getProviderMatchers().getGroupIdentificationConstraints()).getCapabilityMatcher();
+        List<CapabilityMatcher> capm =
+                ((GroupCapabilityConstraintCase) result.getProviderMatchers().getGroupIdentificationConstraints())
+                    .getCapabilityMatcher();
         assertEquals(1, capm.size());
         assertEquals(1, capm.get(0).getMatcherCapability().size());
         assertTrue(containsCapability(capm.get(0).getMatcherCapability(), c1));
@@ -1073,8 +884,9 @@ public class InheritanceUtilsTest {
         assertEquals(MatchType.All, cm.get(0).getMatchType());
         assertEquals(0, cm.get(0).getCondition().size());
 
-        List<RequirementMatcher> pm = 
-                ((GroupRequirementConstraintCase)result.getConsumerMatchers().getGroupIdentificationConstraints()).getRequirementMatcher();
+        List<RequirementMatcher> pm =
+                ((GroupRequirementConstraintCase) result.getConsumerMatchers().getGroupIdentificationConstraints())
+                    .getRequirementMatcher();
         assertEquals(1, pm.size());
         assertEquals(2, pm.get(0).getMatcherRequirement().size());
         assertTrue(containsRequirement(pm.get(0).getMatcherRequirement(), r1));
@@ -1086,9 +898,10 @@ public class InheritanceUtilsTest {
         Tenant tenant = InheritanceUtils.resolveTenant(tenant1);
 
         Contract result = TenantUtils.findContract(tenant, contractId1);
+        assertNotNull(result);
         List<Subject> subjects = result.getSubject();
         assertEquals(1, subjects.size());
-        
+
         assertEquals(s1.getName(), subjects.get(0).getName());
         List<Rule> rules = subjects.get(0).getRule();
         assertEquals(2, rules.size());
@@ -1101,9 +914,10 @@ public class InheritanceUtilsTest {
         Tenant tenant = InheritanceUtils.resolveTenant(tenant1);
 
         Contract result = TenantUtils.findContract(tenant, contractId2);
+        assertNotNull(result);
         List<Subject> subjects = result.getSubject();
         assertEquals(2, subjects.size());
-        for (Subject s: subjects) {
+        for (Subject s : subjects) {
             if (s1.getName().equals(s.getName())) {
                 assertEquals(Integer.valueOf(4), s.getOrder());
                 List<Rule> rules = s.getRule();
@@ -1123,18 +937,23 @@ public class InheritanceUtilsTest {
 
     @Test
     public void testMalformedPolicy() throws Exception {
-        Tenant tenant = 
-                InheritanceUtils.resolveTenant(malformed);
-        Contract c = TenantUtils.findContract(tenant, cloop2Id);
-        assertEquals(1, c.getClause().size());
-        Clause clause = c.getClause().get(0);
+        Tenant tenant = InheritanceUtils.resolveTenant(malformed);
+        Contract contract = TenantUtils.findContract(tenant, cloop2Id);
+        assertNotNull(contract);
+        assertEquals(1, contract.getClause().size());
+        Clause clause = contract.getClause().get(0);
         assertEquals(1, clause.getConsumerMatchers().getConditionMatcher().size());
-        assertEquals(1, ((GroupRequirementConstraintCase)clause.getConsumerMatchers().getGroupIdentificationConstraints()).getRequirementMatcher().size());
+        assertEquals(1,
+                ((GroupRequirementConstraintCase) clause.getConsumerMatchers().getGroupIdentificationConstraints())
+                    .getRequirementMatcher().size());
         assertEquals(1, clause.getProviderMatchers().getConditionMatcher().size());
-        assertEquals(1, ((GroupCapabilityConstraintCase)clause.getProviderMatchers().getGroupIdentificationConstraints()).getCapabilityMatcher().size());
-        assertEquals(2, c.getSubject().size());
+        assertEquals(1,
+                ((GroupCapabilityConstraintCase) clause.getProviderMatchers().getGroupIdentificationConstraints())
+                    .getCapabilityMatcher().size());
+        assertEquals(2, contract.getSubject().size());
 
         EndpointGroup eg = TenantUtils.findEndpointGroup(tenant, egloop2Id);
+        assertNotNull(eg);
         assertEquals(1, eg.getConsumerNamedSelector().size());
         assertEquals(1, eg.getConsumerTargetSelector().size());
         assertEquals(1, eg.getProviderNamedSelector().size());
old mode 100644 (file)
new mode 100755 (executable)
index 408be96..e163e92
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- * 
+ *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
@@ -47,7 +47,7 @@ public class PolicyInfoTest {
     private ConditionSet conditionSet;
 
     @Before
-    public void Initialisation() {
+    public void init() {
         consEgKey = mock(EgKey.class);
         provEgKey = mock(EgKey.class);
         policy = mock(Policy.class);
@@ -56,8 +56,8 @@ public class PolicyInfoTest {
         policyMap.put(consEgKey, provEgKey, policy);
 
         conditionSet = mock(ConditionSet.class);
-        conditionSets = new HashSet<ConditionSet>(Arrays.asList(conditionSet));
-        egConditions = new HashMap<EgKey, Set<ConditionSet>>();
+        conditionSets = new HashSet<>(Collections.singletonList(conditionSet));
+        egConditions = new HashMap<>();
         condEgKey = mock(EgKey.class);
         egConditions.put(condEgKey, conditionSets);
 
@@ -65,7 +65,7 @@ public class PolicyInfoTest {
     }
 
     @Test
-    public void constructorTest() {
+    public void testConstructor() {
         Assert.assertEquals(policyMap, policyInfo.getPolicyMap());
         Assert.assertEquals(policy, policyInfo.getPolicy(consEgKey, provEgKey));
         Assert.assertEquals(Policy.EMPTY, policyInfo.getPolicy(provEgKey, consEgKey));
@@ -73,7 +73,7 @@ public class PolicyInfoTest {
     }
 
     @Test
-    public void getEgCondGroupTest() {
+    public void testGetEgCondGroup() {
         List<ConditionName> conditions = Collections.emptyList();
         ConditionGroup conditionGroup;
 
@@ -87,7 +87,7 @@ public class PolicyInfoTest {
     }
 
     @Test
-    public void getPeersTest() {
+    public void testGetPeers() {
         Set<EgKey> peers;
         peers = policyInfo.getPeers(consEgKey);
         Assert.assertTrue(peers.contains(provEgKey));
old mode 100644 (file)
new mode 100755 (executable)
index 30ea185..1a01140
@@ -8,67 +8,81 @@
 
 package org.opendaylight.groupbasedpolicy.resolver;
 
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.util.Arrays;
+import java.util.Collections;
 import java.util.HashSet;
 
 import org.junit.Assert;
 import org.junit.Test;
-import org.opendaylight.groupbasedpolicy.dto.EgKey;
 import org.opendaylight.groupbasedpolicy.dto.IndexedTenant;
-import org.opendaylight.groupbasedpolicy.dto.Policy;
 import org.opendaylight.groupbasedpolicy.util.PolicyResolverUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ClauseName;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ContractId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.SelectorName;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.SubjectName;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.TargetName;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.TenantId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.Tenant;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.TenantBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.Policy;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.PolicyBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.Contract;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.ContractBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.EndpointGroup;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.EndpointGroupBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.contract.Clause;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.contract.ClauseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.contract.Subject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.contract.SubjectBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.contract.Target;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.contract.TargetBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.endpoint.group.ConsumerNamedSelector;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.endpoint.group.ConsumerNamedSelectorBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.endpoint.group.ConsumerTargetSelector;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.endpoint.group.ConsumerTargetSelectorBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.endpoint.group.ProviderNamedSelector;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.endpoint.group.ProviderNamedSelectorBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.endpoint.group.ProviderTargetSelector;
-
-import com.google.common.collect.Table;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.endpoint.group.ProviderTargetSelectorBuilder;
 
 public class PolicyResolverUtilsTest {
 
     @Test
-    public void resolvePolicyTest() {
-        IndexedTenant indexedTenant = mock(IndexedTenant.class);
-        HashSet<IndexedTenant> tenants = new HashSet<IndexedTenant>();
-        tenants.add(indexedTenant);
-        Tenant tenant = mock(Tenant.class);
-        org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.Policy policy =
-                mock(org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.Policy.class);
-        when(tenant.getPolicy()).thenReturn(policy);
-        when(indexedTenant.getTenant()).thenReturn(tenant);
+    public void testResolvePolicy() {
+        Target target = new TargetBuilder().setName(new TargetName("targetName")).build();
+
+        Clause clause = new ClauseBuilder().setName(ClauseName.getDefaultInstance("clauseName")).build();
+        Subject subject = new SubjectBuilder().setName(new SubjectName("subjectName")).build();
+        ContractId contractId = new ContractId("contractId");
+        Contract contract = new ContractBuilder().setId(contractId)
+            .setTarget(Collections.singletonList(target))
+            .setClause(Collections.singletonList(clause))
+            .setSubject(Collections.singletonList(subject))
+            .build();
+        ProviderNamedSelector pns = new ProviderNamedSelectorBuilder().setName(new SelectorName("pnsName"))
+            .setContract(Collections.singletonList(contractId))
+            .build();
+        ConsumerNamedSelector cns = new ConsumerNamedSelectorBuilder().setName(new SelectorName("cnsName"))
+            .setContract(Collections.singletonList(contractId))
+            .build();
+        ProviderTargetSelector pts = new ProviderTargetSelectorBuilder().setName(new SelectorName("ptsName")).build();
+        ConsumerTargetSelector cts = new ConsumerTargetSelectorBuilder().setName(new SelectorName("ctsName")).build();
 
-        EndpointGroup endpointGroup = mock(EndpointGroup.class);
-        when(policy.getEndpointGroup()).thenReturn(Arrays.asList(endpointGroup));
-        ConsumerNamedSelector cns = mock(ConsumerNamedSelector.class);
-        when(endpointGroup.getConsumerNamedSelector()).thenReturn(Arrays.asList(cns));
-        ContractId contractId = mock(ContractId.class);
-        when(cns.getContract()).thenReturn(Arrays.asList(contractId));
-        Contract contract = mock(Contract.class);
-        when(policy.getContract()).thenReturn(Arrays.asList(contract));
-        when(contract.getId()).thenReturn(contractId);
-        TenantId tenantId = mock(TenantId.class);
-        when(tenant.getId()).thenReturn(tenantId);
+        EndpointGroup endpointGroup =
+                new EndpointGroupBuilder().setProviderNamedSelector(Collections.singletonList(pns))
+                    .setConsumerNamedSelector(Collections.singletonList(cns))
+                    .setProviderTargetSelector(Collections.singletonList(pts))
+                    .setConsumerTargetSelector(Collections.singletonList(cts))
+                    .build();
+        Policy policy = new PolicyBuilder().setEndpointGroup(Collections.singletonList(endpointGroup))
+            .setContract(Collections.singletonList(contract))
+            .build();
+        Tenant tenant = new TenantBuilder().setId(new TenantId("tenantId")).setPolicy(policy).build();
+        IndexedTenant indexedTenant = new IndexedTenant(tenant);
 
-        ProviderNamedSelector pns = mock(ProviderNamedSelector.class);
-        when(endpointGroup.getProviderNamedSelector()).thenReturn(Arrays.asList(pns));
-        ProviderTargetSelector pts = mock(ProviderTargetSelector.class);
-        when(endpointGroup.getProviderTargetSelector()).thenReturn(Arrays.asList(pts));
-        Target t = mock(Target.class);
-        when(contract.getTarget()).thenReturn(Arrays.asList(t));
-        ConsumerTargetSelector cts = mock(ConsumerTargetSelector.class);
-        when(endpointGroup.getConsumerTargetSelector()).thenReturn(Arrays.asList(cts));
+        HashSet<IndexedTenant> indexedTenants = new HashSet<>();
+        indexedTenants.add(indexedTenant);
 
-        Table<EgKey, EgKey, Policy> policyTable = PolicyResolverUtils.resolvePolicy(tenants);
-        Assert.assertEquals(1, policyTable.size());
+        Assert.assertEquals(1, PolicyResolverUtils.resolvePolicy(indexedTenants).size());
     }
 
 }
old mode 100644 (file)
new mode 100755 (executable)
index 9816600..96f23b0
 package org.opendaylight.groupbasedpolicy.resolver;
 
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
-import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
 
-import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.groupbasedpolicy.dto.RuleGroup;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ContractId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.RuleName;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.SubjectName;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.TenantId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.Tenant;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.TenantBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.Contract;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.ContractKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.ContractBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.contract.subject.Rule;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.contract.subject.RuleBuilder;
 
 public class RuleGroupTest {
 
-    private Rule rule;
+    private static final int ORDER = 5;
+    private static final int ORDER_LESSER = 3;
+    private static final int ORDER_BIGGER = 8;
+    private static final String SN_VALUE = "sn_value";
+    private static final String SN_OTHER = "sn_other";
+    private static final String SN_COMES_BEFORE = "sn_armadillo";
+    private static final String SN_COMES_AFTER = "sn_zebra";
+    private static final String RULE_NAME = "ruleName";
+    private static final String RULE_OTHER = "ruleOther";
+    private static final String TENANT_ID = "tenantId";
+    private static final String CONTRACT_ID = "contractId";
+
     private List<Rule> rules;
     private Integer order;
     private Tenant contractTenant;
     private Contract contract;
-    private SubjectName subject;
-    private String subjectValue;
+    private SubjectName subjectName;
 
     private RuleGroup ruleGroup;
 
     @Before
-    public void initialisation() {
-        rule = mock(Rule.class);
-        rules = Arrays.asList(rule);
-        order = Integer.valueOf(5);
-        contractTenant = mock(Tenant.class);
-        contract = mock(Contract.class);
-        subject = mock(SubjectName.class);
-
-        subjectValue = "value";
-        when(subject.getValue()).thenReturn(subjectValue);
-        ContractId contractId = new ContractId("contract");
-        when(contract.getKey()).thenReturn(new ContractKey(contractId));
-
-        ruleGroup = new RuleGroup(rules, order, contractTenant, contract, subject);
+    public void init() {
+        Rule rule = new RuleBuilder().setName(new RuleName(RULE_NAME)).build();
+        rules = Collections.singletonList(rule);
+        order = ORDER;
+        contractTenant = new TenantBuilder().setId(new TenantId(TENANT_ID)).build();
+        contract = new ContractBuilder().setId(new ContractId(CONTRACT_ID)).build();
+        subjectName = new SubjectName(SN_VALUE);
+
+        ruleGroup = new RuleGroup(rules, order, contractTenant, contract, subjectName);
     }
 
     @Test
-    public void constructorTest() {
-        Assert.assertNotNull(ruleGroup);
-        Assert.assertEquals(rules, ruleGroup.getRules());
-        Assert.assertEquals(order, ruleGroup.getOrder());
-        Assert.assertEquals(contractTenant, ruleGroup.getContractTenant());
-        Assert.assertEquals(contract, ruleGroup.getRelatedContract());
-        Assert.assertEquals(subject, ruleGroup.getRelatedSubject());
+    public void testConstructor() {
+        assertNotNull(ruleGroup);
+        assertEquals(rules, ruleGroup.getRules());
+        assertEquals(order, ruleGroup.getOrder());
+        assertEquals(contractTenant, ruleGroup.getContractTenant());
+        assertEquals(contract, ruleGroup.getRelatedContract());
+        assertEquals(subjectName, ruleGroup.getRelatedSubject());
     }
 
     @Test
-    public void equalsTest() {
-        Assert.assertTrue(ruleGroup.equals(ruleGroup));
-        Assert.assertFalse(ruleGroup.equals(null));
-        Assert.assertFalse(ruleGroup.equals(new Object()));
+    public void testEquals() {
+        assertTrue(ruleGroup.equals(ruleGroup));
+        assertFalse(ruleGroup.equals(null));
+        assertFalse(ruleGroup.equals(new Object()));
 
         RuleGroup other;
-        Integer orderOther = Integer.valueOf(3);
-        other = new RuleGroup(rules, orderOther, contractTenant, contract, subject);
-        Assert.assertFalse(ruleGroup.equals(other));
+        Integer orderOther = 3;
+        other = new RuleGroup(rules, orderOther, contractTenant, contract, subjectName);
+        assertFalse(ruleGroup.equals(other));
 
-        Rule ruleOther = mock(Rule.class);
-        List<Rule> rulesOther = Arrays.asList(ruleOther);
-        other = new RuleGroup(rulesOther, order, contractTenant, contract, subject);
-        Assert.assertFalse(ruleGroup.equals(other));
+        Rule ruleOther = new RuleBuilder().setName(new RuleName(RULE_OTHER)).build();
+        List<Rule> rulesOther = Collections.singletonList(ruleOther);
+        other = new RuleGroup(rulesOther, order, contractTenant, contract, subjectName);
+        assertFalse(ruleGroup.equals(other));
 
-        SubjectName subjectOther = mock(SubjectName.class);
-        other = new RuleGroup(rules, order, contractTenant, contract, subjectOther);
-        Assert.assertFalse(ruleGroup.equals(other));
+        SubjectName subjectNameOther = new SubjectName(SN_OTHER);
+        other = new RuleGroup(rules, order, contractTenant, contract, subjectNameOther);
+        assertFalse(ruleGroup.equals(other));
 
-        other = new RuleGroup(rules, order, contractTenant, contract, subject);
-        Assert.assertTrue(ruleGroup.equals(other));
+        other = new RuleGroup(rules, order, contractTenant, contract, this.subjectName);
+        assertTrue(ruleGroup.equals(other));
 
-        ruleGroup = new RuleGroup(rules, null, contractTenant, contract, subject);
-        Assert.assertFalse(ruleGroup.equals(other));
-        other = new RuleGroup(rules, null, contractTenant, contract, subject);
-        Assert.assertTrue(ruleGroup.equals(other));
+        ruleGroup = new RuleGroup(rules, null, contractTenant, contract, this.subjectName);
+        assertFalse(ruleGroup.equals(other));
+        other = new RuleGroup(rules, null, contractTenant, contract, this.subjectName);
+        assertTrue(ruleGroup.equals(other));
 
-        other = new RuleGroup(rules, order, contractTenant, contract, subject);
+        other = new RuleGroup(rules, order, contractTenant, contract, this.subjectName);
         ruleGroup = new RuleGroup(rules, order, contractTenant, contract, null);
-        Assert.assertFalse(ruleGroup.equals(other));
+        assertFalse(ruleGroup.equals(other));
         other = new RuleGroup(rules, order, contractTenant, contract, null);
-        Assert.assertTrue(ruleGroup.equals(other));
+        assertTrue(ruleGroup.equals(other));
     }
 
     @Test
-    public void compareToTest() {
+    public void testCompareTo() {
         RuleGroup other;
-        other = new RuleGroup(rules, order, contractTenant, contract, subject);
-        Assert.assertEquals(0, ruleGroup.compareTo(other));
+        other = new RuleGroup(rules, order, contractTenant, contract, subjectName);
+        assertEquals(0, ruleGroup.compareTo(other));
 
         Integer orderOther;
-        orderOther = Integer.valueOf(3);
-        other = new RuleGroup(rules, orderOther, contractTenant, contract, subject);
-        Assert.assertEquals(1, ruleGroup.compareTo(other));
+        orderOther = ORDER_LESSER;
+        other = new RuleGroup(rules, orderOther, contractTenant, contract, subjectName);
+        assertEquals(1, ruleGroup.compareTo(other));
 
-        orderOther = Integer.valueOf(8);
-        other = new RuleGroup(rules, orderOther, contractTenant, contract, subject);
-        Assert.assertEquals(-1, ruleGroup.compareTo(other));
+        orderOther = ORDER_BIGGER;
+        other = new RuleGroup(rules, orderOther, contractTenant, contract, subjectName);
+        assertEquals(-1, ruleGroup.compareTo(other));
 
-        SubjectName subjectOther = mock(SubjectName.class);
+        SubjectName subjectNameComesBefore = new SubjectName(SN_COMES_BEFORE);
+        SubjectName subjectNameComesLater = new SubjectName(SN_COMES_AFTER);
 
-        when(subjectOther.getValue()).thenReturn("valu");
-        other = new RuleGroup(rules, order, contractTenant, contract, subjectOther);
-        Assert.assertEquals(1, ruleGroup.compareTo(other));
+        other = new RuleGroup(rules, order, contractTenant, contract, subjectNameComesBefore);
+        assertEquals(1, ruleGroup.compareTo(other));
 
-        when(subjectOther.getValue()).thenReturn("valuee");
-        other = new RuleGroup(rules, order, contractTenant, contract, subjectOther);
-        Assert.assertEquals(-1, ruleGroup.compareTo(other));
+        other = new RuleGroup(rules, order, contractTenant, contract, subjectNameComesLater);
+        assertEquals(-1, ruleGroup.compareTo(other));
     }
 
     @Test
-    public void toStringTest() {
+    public void testToString() {
         String string = ruleGroup.toString();
-        Assert.assertNotNull(string);
-        Assert.assertFalse(string.isEmpty());
-        Assert.assertTrue(string.contains(rules.toString()));
-        Assert.assertTrue(string.contains(order.toString()));
+        assertNotNull(string);
+        assertFalse(string.isEmpty());
+        assertTrue(string.contains(rules.toString()));
+        assertTrue(string.contains(order.toString()));
     }
 }
old mode 100644 (file)
new mode 100755 (executable)
index 182fe05..33ed72c
@@ -8,7 +8,10 @@
 \r
 package org.opendaylight.groupbasedpolicy.resolver.validator;\r
 \r
-import org.junit.Assert;\r
+import static org.junit.Assert.assertEquals;\r
+import static org.junit.Assert.assertFalse;\r
+import static org.junit.Assert.assertTrue;\r
+\r
 import org.junit.Before;\r
 import org.junit.Rule;\r
 import org.junit.Test;\r
@@ -21,34 +24,38 @@ public class ValidationResultTest {
     @Rule\r
     public ExpectedException thrown = ExpectedException.none();\r
 \r
+    public static final String VALIDATED = "Validated.";\r
+    public static final String EMPTY_STRING = "";\r
+\r
     ValidationResultBuilder resultBuilder;\r
-    ValidationResult result;\r
 \r
     @Before\r
-    public void initialisation() {\r
+    public void init() {\r
         resultBuilder = new ValidationResultBuilder();\r
     }\r
 \r
     @Test\r
-    public void successValidationTest() {\r
-        result = resultBuilder.success().build();\r
-        Assert.assertTrue(result.isValid());\r
-        Assert.assertTrue(result.getMessage().equals(""));\r
+    public void testBuild_WithSuccess() {\r
+        ValidationResult result = resultBuilder.success().build();\r
+        assertTrue(result.isValid());\r
+        assertEquals(EMPTY_STRING, result.getMessage());\r
     }\r
 \r
     @Test\r
-    public void unsuccessValidationTest() {\r
-        result = resultBuilder.failed().build();\r
-        Assert.assertFalse(result.isValid());\r
-        Assert.assertTrue(result.getMessage().equals(""));\r
+    public void testBuild_WithFailed() {\r
+        ValidationResult result = resultBuilder.failed().build();\r
+        assertFalse(result.isValid());\r
+        assertEquals(EMPTY_STRING, result.getMessage());\r
     }\r
 \r
     @Test\r
-    public void messageTest() {\r
-        result = resultBuilder.setMessage("Validated.").build();\r
-        Assert.assertTrue(result.getMessage().equals("Validated."));\r
+    public void testMessage() {\r
+        ValidationResult result = resultBuilder.setMessage(VALIDATED).build();\r
+\r
+        assertEquals(VALIDATED, result.getMessage());\r
+\r
         thrown.expect(IllegalArgumentException.class);\r
-        thrown.expectMessage("Result message cannot be set to NULL!");\r
+        thrown.expectMessage(ValidationResultBuilder.ILLEGAL_ARG_EX_MSG);\r
         resultBuilder.setMessage(null);\r
     }\r
 \r
old mode 100644 (file)
new mode 100755 (executable)
index b8f1987..f4ee76e
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
- * 
+ *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
@@ -15,6 +15,8 @@ import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.CheckedFuture;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -26,11 +28,10 @@ import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
-
 public class DataStoreHelperTest {
 
+    private static final String EXCEPTION_MESSAGE = "test exception";
+
     private ReadOnlyTransaction readTransaction;
     private WriteTransaction writeTransaction;
     private ReadWriteTransaction readWriteTransaction;
@@ -38,56 +39,50 @@ public class DataStoreHelperTest {
     private CheckedFuture<Optional<?>, ReadFailedException> readFuture;
     private CheckedFuture<Void, TransactionCommitFailedException> submitFuture;
 
-    @SuppressWarnings("unchecked")
     @Before
-    public void initialise() {
+    public void init() {
         readTransaction = mock(ReadOnlyTransaction.class);
         readFuture = mock(CheckedFuture.class);
-        when(readTransaction.read(any(LogicalDatastoreType.class), any(InstanceIdentifier.class))).thenReturn(
-                readFuture);
+        when(readTransaction.read(any(LogicalDatastoreType.class), any(InstanceIdentifier.class)))
+            .thenReturn(readFuture);
 
         writeTransaction = mock(WriteTransaction.class);
         submitFuture = mock(CheckedFuture.class);
         when(writeTransaction.submit()).thenReturn(submitFuture);
 
         readWriteTransaction = mock(ReadWriteTransaction.class);
-        when(readWriteTransaction.read(any(LogicalDatastoreType.class), any(InstanceIdentifier.class))).thenReturn(
-                readFuture);
+        when(readWriteTransaction.read(any(LogicalDatastoreType.class), any(InstanceIdentifier.class)))
+            .thenReturn(readFuture);
     }
 
-    @SuppressWarnings({"unchecked", "rawtypes"})
     @Test
-    public void readFromDsTest() throws Exception {
+    public void testReadFromDs() throws Exception {
         Optional<?> optional = mock(Optional.class);
         when(readFuture.checkedGet()).thenReturn((Optional) optional);
         Assert.assertEquals(optional, DataStoreHelper.readFromDs(LogicalDatastoreType.OPERATIONAL,
                 mock(InstanceIdentifier.class), readTransaction));
     }
 
-    @SuppressWarnings("unchecked")
     @Test
-    public void readFromDsTestException() throws Exception {
-        @SuppressWarnings("unused")
-        Optional<?> optional = mock(Optional.class);
-        doThrow(mock(ReadFailedException.class)).when(readFuture).checkedGet();
+    public void testReadFromDs_Exception() throws Exception {
+        doThrow(new ReadFailedException(EXCEPTION_MESSAGE)).when(readFuture).checkedGet();
         Assert.assertEquals(Optional.absent(), DataStoreHelper.readFromDs(LogicalDatastoreType.OPERATIONAL,
                 mock(InstanceIdentifier.class), readTransaction));
     }
 
     @Test
-    public void submitToDsTest() {
+    public void testSubmitToDs() {
         Assert.assertTrue(DataStoreHelper.submitToDs(writeTransaction));
     }
 
     @Test
-    public void submitToDsTestException() throws Exception {
-        doThrow(mock(TransactionCommitFailedException.class)).when(submitFuture).checkedGet();
+    public void testSubmitToDs_Exception() throws Exception {
+        doThrow(new TransactionCommitFailedException(EXCEPTION_MESSAGE)).when(submitFuture).checkedGet();
         Assert.assertFalse(DataStoreHelper.submitToDs(writeTransaction));
     }
 
-    @SuppressWarnings({"unchecked", "rawtypes"})
     @Test
-    public void removeIfExistsTest() throws Exception {
+    public void testRemoveIfExists() throws Exception {
         Optional<?> optional = mock(Optional.class);
         when(optional.isPresent()).thenReturn(true);
         when(readFuture.checkedGet()).thenReturn((Optional) optional);
@@ -96,9 +91,8 @@ public class DataStoreHelperTest {
         verify(readWriteTransaction).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
     }
 
-    @SuppressWarnings({"unchecked", "rawtypes"})
     @Test
-    public void removeIfExistsTestException() throws Exception {
+    public void testRemoveIfExists_NotExisting() throws Exception {
         Optional<?> optional = mock(Optional.class);
         when(optional.isPresent()).thenReturn(false);
         when(readFuture.checkedGet()).thenReturn((Optional) optional);
old mode 100644 (file)
new mode 100755 (executable)
index 539d9d0..08f7553
@@ -8,41 +8,41 @@
 
 package org.opendaylight.groupbasedpolicy.util;
 
-import java.util.Arrays;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Collections;
 import java.util.HashSet;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 
-import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 
 public class SetUtilsTest {
 
     private Object key;
-    private Object value;
     private Set<Object> nestedSet;
     private ConcurrentMap<Object, Set<Object>> concurrentMap;
 
     @Before
-    public void initialise() {
+    public void init() {
         key = new Object();
-        value = new Object();
-        nestedSet = new HashSet<Object>(Arrays.asList(value));
-        concurrentMap = new ConcurrentHashMap<Object, Set<Object>>();
+        nestedSet = new HashSet<>(Collections.singletonList(new Object()));
+        concurrentMap = new ConcurrentHashMap<>();
     }
 
     @Test
-    public void getNestedSetTest() {
+    public void testGetNestedSet() {
         concurrentMap.put(key, nestedSet);
         Set<Object> inner = SetUtils.getNestedSet(key, concurrentMap);
-        Assert.assertEquals(nestedSet, inner);
+        assertEquals(nestedSet, inner);
     }
 
     @Test
-    public void getNestedSetTestInnerNull() {
+    public void testGetNestedSet_InnerNull() {
         Set<Object> inner = SetUtils.getNestedSet(key, concurrentMap);
-        Assert.assertTrue(inner.isEmpty());
+        assertTrue(inner.isEmpty());
     }
 }