X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fconfig%2Fyang-jmx-generator%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fyangjmxgenerator%2FRuntimeBeanEntryTest.java;h=e80ebc67a566197294ac64e2c431dd07c5131b3c;hb=8e42b08cb626a60919c145b2a46d94114c3905d6;hp=597cf4ccc9d1cf033cb6ae919662c69ec89008f0;hpb=9fb64948564e252018f9b1e13e7cea2c92f991aa;p=controller.git diff --git a/opendaylight/config/yang-jmx-generator/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/RuntimeBeanEntryTest.java b/opendaylight/config/yang-jmx-generator/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/RuntimeBeanEntryTest.java index 597cf4ccc9..e80ebc67a5 100644 --- a/opendaylight/config/yang-jmx-generator/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/RuntimeBeanEntryTest.java +++ b/opendaylight/config/yang-jmx-generator/src/test/java/org/opendaylight/controller/config/yangjmxgenerator/RuntimeBeanEntryTest.java @@ -7,14 +7,16 @@ */ package org.opendaylight.controller.config.yangjmxgenerator; -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertThat; +import static junit.framework.Assert.assertNotNull; +import static junit.framework.Assert.assertNull; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.doReturn; import java.util.ArrayList; import java.util.Collection; +import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -27,6 +29,7 @@ import org.opendaylight.controller.config.yangjmxgenerator.attribute.JavaAttribu import org.opendaylight.yangtools.sal.binding.yang.types.TypeProviderImpl; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode; +import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode; import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode; @@ -41,6 +44,7 @@ public class RuntimeBeanEntryTest extends AbstractYangTest { public static final String SLEEP_RPC_OUTPUT = "ThreadState"; public static final String SLEEP_RPC_INPUT_NAME = "millis"; public static final String SLEEP_RPC_INPUT_TYPE = "Long"; + private static final Map identitiesToSIs = new HashMap<>(); @Test public void createRuntimeBean() { @@ -51,17 +55,17 @@ public class RuntimeBeanEntryTest extends AbstractYangTest { Map runtimeBeans = RuntimeBeanEntry .extractClassNameToRuntimeBeanMap(PACKAGE_NAME, caseNode, "test-name", new TypeProviderWrapper(new TypeProviderImpl(context)), "test", jmxImplModule); - assertThat(runtimeBeans.size(), is(1)); + assertEquals(1, runtimeBeans.size()); RuntimeBeanEntry runtimeMXBean = runtimeBeans.get("testRuntimeMXBean"); - assertThat(runtimeMXBean.isRoot(), is(true)); - assertThat(runtimeMXBean.getYangName(), is("test-name")); + assertTrue(runtimeMXBean.isRoot()); + assertEquals("test-name", runtimeMXBean.getYangName()); } @Test public void runtimeBeanRPCTest() { // create service interfaces Map modulesToSIEs = ServiceInterfaceEntry - .create(threadsModule, "packages.sis"); + .create(threadsModule, "packages.sis",identitiesToSIs); assertNotNull(modulesToSIEs); // create MXBeans map @@ -69,7 +73,7 @@ public class RuntimeBeanEntryTest extends AbstractYangTest { threadsJavaModule, modulesToSIEs, context, new TypeProviderWrapper(new TypeProviderImpl(context)), PACKAGE_NAME); - assertThat(namesToMBEs.isEmpty(), is(false)); + assertFalse(namesToMBEs.isEmpty()); // get threadfactory-naming bean ModuleMXBeanEntry threadfactoryNamingMXBean = namesToMBEs @@ -79,13 +83,13 @@ public class RuntimeBeanEntryTest extends AbstractYangTest { // get runtime beans Collection runtimeBeanEntries = threadfactoryNamingMXBean .getRuntimeBeans(); - assertThat(runtimeBeanEntries.isEmpty(), is(false)); + assertFalse(runtimeBeanEntries.isEmpty()); // get root runtime bean RuntimeBeanEntry threadfactoryRuntimeBeanEntry = getRuntimeBeanEntryByJavaName( runtimeBeanEntries, "NamingThreadFactoryRuntimeMXBean"); assertNotNull(threadfactoryRuntimeBeanEntry); - assertThat(threadfactoryRuntimeBeanEntry.isRoot(), is(true)); + assertTrue(threadfactoryRuntimeBeanEntry.isRoot()); // get thread runtime bean RuntimeBeanEntry runtimeBeanEntry = getRuntimeBeanEntryByJavaName( @@ -93,42 +97,41 @@ public class RuntimeBeanEntryTest extends AbstractYangTest { assertNotNull(runtimeBeanEntry); // test thread runtime bean properties - assertThat(runtimeBeanEntry.getJavaNamePrefix(), - is(THREAD_RUNTIME_BEAN_JAVA_PREFIX)); - assertThat(runtimeBeanEntry.getPackageName(), is(PACKAGE_NAME)); - assertThat(runtimeBeanEntry.getFullyQualifiedName(runtimeBeanEntry - .getJavaNameOfRuntimeMXBean()), is(PACKAGE_NAME + "." - + THREAD_RUNTIME_BEAN_JAVA_NAME)); - assertThat(runtimeBeanEntry.getYangName(), - is(THREAD_RUNTIME_BEAN_YANG_NAME)); + assertEquals(THREAD_RUNTIME_BEAN_JAVA_PREFIX, runtimeBeanEntry.getJavaNamePrefix()); + assertEquals(PACKAGE_NAME, runtimeBeanEntry.getPackageName()); + assertEquals(PACKAGE_NAME + "." + THREAD_RUNTIME_BEAN_JAVA_NAME, + runtimeBeanEntry.getFullyQualifiedName(runtimeBeanEntry + .getJavaNameOfRuntimeMXBean())); + assertEquals(THREAD_RUNTIME_BEAN_YANG_NAME, runtimeBeanEntry.getYangName()); // get thread runtime bean rpcs List rpcs = new ArrayList( runtimeBeanEntry.getRpcs()); - assertThat(rpcs.size(), is(2)); + assertEquals(2, rpcs.size()); // get sleep rpc and test it RuntimeBeanEntry.Rpc rpc = getRpcByName(rpcs, SLEEP_RPC_NAME); assertNotNull(rpc); - assertThat(rpc.getYangName(), is(SLEEP_RPC_NAME)); - assertThat(rpc.getReturnType().endsWith(SLEEP_RPC_OUTPUT), is(true)); + assertEquals(SLEEP_RPC_NAME, rpc.getYangName()); + + assertTrue(((JavaAttribute)rpc.getReturnType()).getType().getFullyQualifiedName().endsWith(SLEEP_RPC_OUTPUT)); // get sleep rpc input attribute and test it List attributes = rpc.getParameters(); - assertThat(attributes.size(), is(1)); + assertEquals(1, attributes.size()); JavaAttribute attribute = attributes.get(0); - assertThat(attribute.getAttributeYangName(), is(SLEEP_RPC_INPUT_NAME)); - assertThat(attribute.getType().getName(), is(SLEEP_RPC_INPUT_TYPE)); - assertThat(attribute.getLowerCaseCammelCase(), is(SLEEP_RPC_INPUT_NAME)); - assertThat(attribute.getUpperCaseCammelCase(), is("Millis")); + assertEquals(SLEEP_RPC_INPUT_NAME, attribute.getAttributeYangName()); + assertEquals(SLEEP_RPC_INPUT_TYPE, attribute.getType().getName()); + assertEquals(SLEEP_RPC_INPUT_NAME, attribute.getLowerCaseCammelCase()); + assertEquals("Millis", attribute.getUpperCaseCammelCase()); assertNull(attribute.getNullableDefault()); assertNull(attribute.getNullableDescription()); - assertThat(attribute.getOpenType(), is(SimpleType.class)); + assertTrue(attribute.getOpenType() instanceof SimpleType); } private RuntimeBeanEntry getRuntimeBeanEntryByJavaName( final Collection runtimeBeanEntries, - String javaName) { + final String javaName) { if (runtimeBeanEntries != null && !runtimeBeanEntries.isEmpty()) { for (RuntimeBeanEntry runtimeBeanEntry : runtimeBeanEntries) { if (runtimeBeanEntry.getJavaNameOfRuntimeMXBean().equals( @@ -141,7 +144,7 @@ public class RuntimeBeanEntryTest extends AbstractYangTest { } private RuntimeBeanEntry.Rpc getRpcByName( - final List rpcs, String name) { + final List rpcs, final String name) { if (rpcs != null && !rpcs.isEmpty()) { for (RuntimeBeanEntry.Rpc rpc : rpcs) { if (rpc.getName().equals(name)) {