Coverage - NodeConfigServiceImpl. 00/24700/1
authorJozef Gloncak <jgloncak@cisco.com>
Fri, 31 Jul 2015 12:09:05 +0000 (14:09 +0200)
committerJozef Gloncak <jgloncak@cisco.com>
Fri, 31 Jul 2015 12:09:38 +0000 (14:09 +0200)
Increase code coverage for NodeConfigServiceImpl.

Change-Id: I0cce5a9e3cde42bf79a3bbf3b457450be1eb9f30
Signed-off-by: Jozef Gloncak <jgloncak@cisco.com>
openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/NodeConfigServiceImplTest.java [new file with mode: 0644]

diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/NodeConfigServiceImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/NodeConfigServiceImplTest.java
new file mode 100644 (file)
index 0000000..d4e564b
--- /dev/null
@@ -0,0 +1,45 @@
+package org.opendaylight.openflowplugin.impl.services;
+
+import org.junit.Test;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.module.config.rev141015.NodeConfigService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.module.config.rev141015.SetConfigInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.module.config.rev141015.SetConfigInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.SwitchConfigFlag;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.verify;
+
+public class NodeConfigServiceImplTest extends ServiceMocking{
+
+    private static final Long DUMMY_XID_VALUE = 150L;
+    private static final SwitchConfigFlag DUMMY_FLAG = SwitchConfigFlag.FRAGNORMAL;
+    private static final String DUMMY_FLAG_STR = "FRAGNORMAL";
+    private static final Integer DUMMY_MISS_SEARCH_LENGTH = 3000;
+    NodeConfigServiceImpl nodeConfigService;
+
+    @Test
+    public void testSetConfig() throws Exception {
+        nodeConfigService = new NodeConfigServiceImpl(mockedRequestContextStack, mockedDeviceContext);
+        SetConfigInput setConfigInput = new SetConfigInputBuilder().build();
+        nodeConfigService.setConfig(setConfigInput);
+        verify(mockedRequestContextStack).createRequestContext();
+    }
+
+    @Test
+    public void testBuildRequest() throws Exception {
+        nodeConfigService = new NodeConfigServiceImpl(mockedRequestContextStack, mockedDeviceContext);
+        SetConfigInputBuilder setConfigInputBuilder = new SetConfigInputBuilder();
+        setConfigInputBuilder.setFlag(DUMMY_FLAG_STR);
+        setConfigInputBuilder.setMissSearchLength(DUMMY_MISS_SEARCH_LENGTH);
+        final OfHeader request = nodeConfigService.buildRequest(new Xid(DUMMY_XID_VALUE), setConfigInputBuilder.build());
+
+        assertTrue(request instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput);
+        org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput setConfigInput
+                = (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput) request;
+        assertEquals(DUMMY_FLAG,setConfigInput.getFlags());
+        assertEquals(DUMMY_MISS_SEARCH_LENGTH, setConfigInput.getMissSendLen());
+        assertEquals(DUMMY_XID_VALUE, setConfigInput.getXid());
+    }
+}
\ No newline at end of file