public synchronized BigInteger getDatapathID(ConnectionAdapter connectionAdapter) throws NullPointerException { if (connectionAdapterMap.containsKey(connectionAdapter)) { GetFeaturesOutput obj = connectionAdapterMap.get(connectionAdapter); if (obj != null) { return obj.getDatapathId(); } } return null; }
/** Initializes mocks */ @Before public void startUp() { MockitoAnnotations.initMocks(this); when(sc.getPrimaryConductor()).thenReturn(conductor); when(conductor.getVersion()).thenReturn((short) EncodeConstants.OF13_VERSION_ID); when(sc.getFeatures()).thenReturn(features); when(features.getDatapathId()).thenReturn(new BigInteger("42")); }
@Test public void testPortStatusMessage() { PortStatusMessage mockedPortStatusMessage = mock(PortStatusMessage.class); Class dummyClass = Class.class; when(mockedPortStatusMessage.getImplementedInterface()).thenReturn(dummyClass); GetFeaturesOutput mockedFeature = mock(GetFeaturesOutput.class); when(mockedFeature.getDatapathId()).thenReturn(DUMMY_DATAPATH_ID); when(deviceState.getFeatures()).thenReturn(mockedFeature); when(mockedPortStatusMessage.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3); when(mockedPortStatusMessage.getReason()).thenReturn(PortReason.OFPPRADD); OpenflowPortsUtil.init(); deviceContext.processPortStatusMessage(mockedPortStatusMessage); verify(txChainManager) .writeToTransaction( eq(LogicalDatastoreType.OPERATIONAL), any(InstanceIdentifier.class), any(DataObject.class)); }