Bug 5540 - ConvertorManager DataContainer source, one Convertor interface
[openflowplugin.git] / openflowplugin-impl / src / test / java / org / opendaylight / openflowplugin / impl / services / SalFlowServiceImplTest.java
index 6600c9e8a5ec0ab102e997dad54ed54643cd6335..070cf5e32bb2f323c149d3284d15af83f0ef577f 100644 (file)
@@ -45,12 +45,16 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.ta
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.OriginalFlow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.OriginalFlowBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlowBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowRef;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
@@ -145,7 +149,11 @@ public class SalFlowServiceImplTest extends TestCase {
 
     @Test
     public void testAddFlowFailCallback() throws Exception {
-        AddFlowInput mockedAddFlowInput = createFlowMock(AddFlowInput.class);
+        AddFlowInput mockedAddFlowInput = new AddFlowInputBuilder()
+                .setMatch(match)
+                .setTableId((short)1)
+                .build();
+
         Mockito.doReturn(Futures.<RequestContext<Object>>immediateFailedFuture(new Exception("ut-failed-response")))
                 .when(requestContext).getFuture();
 
@@ -160,7 +168,10 @@ public class SalFlowServiceImplTest extends TestCase {
 
     @Test
     public void testRemoveFlowFailCallback() throws Exception {
-        RemoveFlowInput mockedRemoveFlowInput = createFlowMock(RemoveFlowInput.class);
+        RemoveFlowInput mockedRemoveFlowInput = new RemoveFlowInputBuilder()
+                .setMatch(match)
+                .build();
+
         Mockito.doReturn(Futures.<RequestContext<Object>>immediateFailedFuture(new Exception("ut-failed-response")))
                 .when(requestContext).getFuture();
 
@@ -178,7 +189,11 @@ public class SalFlowServiceImplTest extends TestCase {
     }
 
     private void addFlow(final ItemLifecycleListener itemLifecycleListener) throws ExecutionException, InterruptedException {
-        AddFlowInput mockedAddFlowInput = createFlowMock(AddFlowInput.class);
+        AddFlowInput mockedAddFlowInput = new AddFlowInputBuilder()
+                .setMatch(match)
+                .setTableId((short)1)
+                .build();
+
         salFlowService.setItemLifecycleListener(itemLifecycleListener);
 
         mockingFlowRegistryLookup();
@@ -199,7 +214,10 @@ public class SalFlowServiceImplTest extends TestCase {
     }
 
     private void removeFlow(final ItemLifecycleListener itemLifecycleListener) throws Exception {
-        RemoveFlowInput mockedRemoveFlowInput = createFlowMock(RemoveFlowInput.class);
+        RemoveFlowInput mockedRemoveFlowInput = new RemoveFlowInputBuilder()
+                .setMatch(match)
+                .setTableId((short)1)
+                .build();
 
         if (itemLifecycleListener != null) {
             salFlowService.setItemLifecycleListener(itemLifecycleListener);
@@ -227,14 +245,22 @@ public class SalFlowServiceImplTest extends TestCase {
     private void updateFlow(final ItemLifecycleListener itemLifecycleListener) throws Exception {
         UpdateFlowInput mockedUpdateFlowInput = mock(UpdateFlowInput.class);
 
-        UpdatedFlow mockedUpdateFlow = createFlowMock(UpdatedFlow.class);
+        UpdatedFlow mockedUpdateFlow = new UpdatedFlowBuilder()
+                .setMatch(match)
+                .setTableId((short)1)
+                .build();
+
         when(mockedUpdateFlowInput.getUpdatedFlow()).thenReturn(mockedUpdateFlow);
 
         FlowRef mockedFlowRef = mock(FlowRef.class);
         Mockito.doReturn(TABLE_II.child(Flow.class, new FlowKey(new FlowId(DUMMY_FLOW_ID)))).when(mockedFlowRef).getValue();
         when(mockedUpdateFlowInput.getFlowRef()).thenReturn(mockedFlowRef);
 
-        OriginalFlow mockedOriginalFlow = createFlowMock(OriginalFlow.class);
+        OriginalFlow mockedOriginalFlow = new OriginalFlowBuilder()
+                .setMatch(match)
+                .setTableId((short)1)
+                .build();
+
         when(mockedUpdateFlowInput.getOriginalFlow()).thenReturn(mockedOriginalFlow);
 
         if (itemLifecycleListener != null) {
@@ -266,10 +292,4 @@ public class SalFlowServiceImplTest extends TestCase {
         assertNotNull(addFlowOutputRpcResult);
         assertTrue(addFlowOutputRpcResult.isSuccessful());
     }
-
-    private <T extends org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow> T createFlowMock(Class<T> flowClazz) {
-        T mockedFlow = mock(flowClazz);
-        when(mockedFlow.getMatch()).thenReturn(match);
-        return mockedFlow;
-    }
 }