From 52ca95eed2ae072dc71cbe61e081d5fed6c7a04d Mon Sep 17 00:00:00 2001 From: Jozef Gloncak Date: Fri, 31 Jul 2015 14:09:05 +0200 Subject: [PATCH] Coverage - NodeConfigServiceImpl. Increase code coverage for NodeConfigServiceImpl. Change-Id: I0cce5a9e3cde42bf79a3bbf3b457450be1eb9f30 Signed-off-by: Jozef Gloncak --- .../services/NodeConfigServiceImplTest.java | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/NodeConfigServiceImplTest.java 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 index 0000000000..d4e564b792 --- /dev/null +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/NodeConfigServiceImplTest.java @@ -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 -- 2.36.6