Sho SHIMIZU
Committed by Gerrit Code Review

Prohibit null in instantiation

Change-Id: If5229337d1531eae25cbd2b31ca8e6a117d022f3
...@@ -42,6 +42,9 @@ public final class IntentOperations { ...@@ -42,6 +42,9 @@ public final class IntentOperations {
42 * @param operations list of intent operations 42 * @param operations list of intent operations
43 */ 43 */
44 private IntentOperations(List<IntentOperation> operations, ApplicationId appId) { 44 private IntentOperations(List<IntentOperation> operations, ApplicationId appId) {
45 + checkNotNull(operations);
46 + checkNotNull(appId);
47 +
45 this.operations = operations; 48 this.operations = operations;
46 this.appId = appId; 49 this.appId = appId;
47 } 50 }
......
...@@ -20,6 +20,8 @@ import java.util.List; ...@@ -20,6 +20,8 @@ import java.util.List;
20 import org.junit.After; 20 import org.junit.After;
21 import org.junit.Before; 21 import org.junit.Before;
22 import org.junit.Test; 22 import org.junit.Test;
23 +import org.onosproject.core.ApplicationId;
24 +import org.onosproject.core.DefaultApplicationId;
23 import org.onosproject.core.IdGenerator; 25 import org.onosproject.core.IdGenerator;
24 import org.onosproject.net.ConnectPoint; 26 import org.onosproject.net.ConnectPoint;
25 import org.onosproject.net.NetTestTools; 27 import org.onosproject.net.NetTestTools;
...@@ -43,6 +45,8 @@ public class IntentOperationsTest { ...@@ -43,6 +45,8 @@ public class IntentOperationsTest {
43 final TrafficSelector selector = new IntentTestsMocks.MockSelector(); 45 final TrafficSelector selector = new IntentTestsMocks.MockSelector();
44 final IntentTestsMocks.MockTreatment treatment = new IntentTestsMocks.MockTreatment(); 46 final IntentTestsMocks.MockTreatment treatment = new IntentTestsMocks.MockTreatment();
45 47
48 + private final ApplicationId appId = new DefaultApplicationId((short) 1, "IntentOperationsTest");
49 +
46 private Intent intent; 50 private Intent intent;
47 protected IdGenerator idGenerator = new MockIdGenerator(); 51 protected IdGenerator idGenerator = new MockIdGenerator();
48 52
...@@ -78,15 +82,15 @@ public class IntentOperationsTest { ...@@ -78,15 +82,15 @@ public class IntentOperationsTest {
78 @Test 82 @Test
79 public void testEquals() { 83 public void testEquals() {
80 final IntentOperations operations1 = 84 final IntentOperations operations1 =
81 - IntentOperations.builder(null) //FIXME null 85 + IntentOperations.builder(appId)
82 .addSubmitOperation(intent) 86 .addSubmitOperation(intent)
83 .build(); 87 .build();
84 final IntentOperations sameAsOperations1 = 88 final IntentOperations sameAsOperations1 =
85 - IntentOperations.builder(null) //FIXME null 89 + IntentOperations.builder(appId)
86 .addSubmitOperation(intent) 90 .addSubmitOperation(intent)
87 .build(); 91 .build();
88 final IntentOperations operations2 = 92 final IntentOperations operations2 =
89 - IntentOperations.builder(null) //FIXME null 93 + IntentOperations.builder(appId)
90 .addReplaceOperation(intent.id(), intent) 94 .addReplaceOperation(intent.id(), intent)
91 .build(); 95 .build();
92 96
...@@ -102,7 +106,7 @@ public class IntentOperationsTest { ...@@ -102,7 +106,7 @@ public class IntentOperationsTest {
102 @Test 106 @Test
103 public void testConstruction() { 107 public void testConstruction() {
104 final IntentOperations operations = 108 final IntentOperations operations =
105 - IntentOperations.builder(null) //FIXME 109 + IntentOperations.builder(appId)
106 .addUpdateOperation(intent.id()) 110 .addUpdateOperation(intent.id())
107 .addWithdrawOperation(intent.id()) 111 .addWithdrawOperation(intent.id())
108 .build(); 112 .build();
......