@Test public void testFlowHandling() throws Exception { CheckedFuture matchitemdefinitionFuture = mock(CheckedFuture.class); ReadOnlyTransaction readOnlyTransaction = mock(ReadOnlyTransaction.class); when(dataBroker.newReadOnlyTransaction()).thenReturn(readOnlyTransaction); when(readOnlyTransaction.read(any(LogicalDatastoreType.class), any(InstanceIdentifier.class))).thenReturn(matchitemdefinitionFuture); List<MatchItemDefinition> matchItemDefinitions = new ArrayList<MatchItemDefinition>(); MatchItemDefinition matchItemDefinition = mock(MatchItemDefinition.class); matchItemDefinitions.add(matchItemDefinition); when(matchItemDefinition.getMatchItemName()).thenReturn(matchItemName); Class<UpdateFlow> class1 = UpdateFlow.class; Class<GetDefinitions> class2 = GetDefinitions.class; Field field = class1.getDeclaredField("getDefinitions"); field.setAccessible(true); Field field1 = class2.getDeclaredField("matchItemDefinitionList"); field1.setAccessible(true); field1.set(field.get(updateFlow), matchItemDefinitions); when(flow.getMatchItem()).thenReturn(null); when(tenantManage.getFlow(userId)).thenReturn(null); when(tenantManage.getFlowDataStore(userId)).thenReturn(null); doNothing().when(tenantManage).setFlow(any(UserId.class),any(FlowId.class),any(Flow.class)); Assert.assertEquals(updateFlow.FlowHandling(userId, flow), null); }
public String FlowHandling(UserId userId, Flow flow){ String errorInfo = null; errorInfo = checkDefinition(flow); if (errorInfo!=null){ return errorInfo; } else { errorInfo = checkInstance(userId,flow); if (errorInfo!=null){ return errorInfo; } else { tenantManage.setFlow(userId,flow.getFlowId(),flow); } } return null; }
UpdateFlow { public String FlowHandling(UserId userId, Flow flow){ String errorInfo = null; errorInfo = checkDefinition(flow); if (errorInfo!=null){ return errorInfo; } else { errorInfo = checkInstance(userId,flow); if (errorInfo!=null){ return errorInfo; } else { tenantManage.setFlow(userId,flow.getFlowId(),flow); } } return null; } }
UpdateFlow { public String FlowHandling(UserId userId, Flow flow){ String errorInfo = null; errorInfo = checkDefinition(flow); if (errorInfo!=null){ return errorInfo; } else { errorInfo = checkInstance(userId,flow); if (errorInfo!=null){ return errorInfo; } else { tenantManage.setFlow(userId,flow.getFlowId(),flow); } } return null; } UpdateFlow(DataBroker dataBroker, TenantManage tenantManage); }
UpdateFlow { public String FlowHandling(UserId userId, Flow flow){ String errorInfo = null; errorInfo = checkDefinition(flow); if (errorInfo!=null){ return errorInfo; } else { errorInfo = checkInstance(userId,flow); if (errorInfo!=null){ return errorInfo; } else { tenantManage.setFlow(userId,flow.getFlowId(),flow); } } return null; } UpdateFlow(DataBroker dataBroker, TenantManage tenantManage); String FlowHandling(UserId userId, Flow flow); }
UpdateFlow { public String FlowHandling(UserId userId, Flow flow){ String errorInfo = null; errorInfo = checkDefinition(flow); if (errorInfo!=null){ return errorInfo; } else { errorInfo = checkInstance(userId,flow); if (errorInfo!=null){ return errorInfo; } else { tenantManage.setFlow(userId,flow.getFlowId(),flow); } } return null; } UpdateFlow(DataBroker dataBroker, TenantManage tenantManage); String FlowHandling(UserId userId, Flow flow);  }