package org.opendaylight.controller.config.yangjmxgenerator;
import com.google.common.collect.Sets;
+import java.util.HashMap;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.controller.config.yangjmxgenerator.attribute.AttributeIfc;
import org.opendaylight.yangtools.sal.binding.yang.types.TypeProviderImpl;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath;
import javax.management.openmbean.ArrayType;
@Before
public void setUp() {
+ Map<IdentitySchemaNode, ServiceInterfaceEntry> identitiesToSIs = new HashMap<>();
modulesToSIEs = ServiceInterfaceEntry.create(threadsModule,
- "packages.sis");
+ "packages.sis",identitiesToSIs);
}
@Test
public void test_jmxImplModule() {
+ Map<IdentitySchemaNode, ServiceInterfaceEntry> identitiesToSIs = new HashMap<>();
Map<QName, ServiceInterfaceEntry> modulesToSIEs = ServiceInterfaceEntry
- .create(threadsModule, PACKAGE_NAME);
+ .create(threadsModule, PACKAGE_NAME,identitiesToSIs);
modulesToSIEs.putAll(ServiceInterfaceEntry.create(jmxModule,
- PACKAGE_NAME));
+ PACKAGE_NAME,identitiesToSIs));
Map<String /* identity local name */, ModuleMXBeanEntry> namesToMBEs = ModuleMXBeanEntry
.create(jmxImplModule, modulesToSIEs, context, new TypeProviderWrapper(new TypeProviderImpl(context))
, PACKAGE_NAME);
Map<String, AttributeIfc> attributes = namesToMBEs.get("impl-netconf")
.getAttributes();
+
+ assertCorrectAttributesSize(namesToMBEs, attributes);
+
//
DependencyAttribute threadFactoryAttribute = (DependencyAttribute) attributes
.get("thread-factory");
assertThat(threadFactoryAttribute.getType().getName(), is("ObjectName"));
}
+ private void assertCorrectAttributesSize(Map<String, ModuleMXBeanEntry> namesToMBEs, Map<String, AttributeIfc> attributes) {
+ assertEquals(14, attributes.size());
+ assertEquals(1, namesToMBEs.get("impl-netconf").getRuntimeBeans().size());
+ assertEquals(2, namesToMBEs.get("impl-netconf").getRuntimeBeans().iterator().next().getAttributes().size());
+
+ assertEquals(4, namesToMBEs.get("impl").getAttributes().size());
+ assertEquals(1, namesToMBEs.get("impl").getRuntimeBeans().size());
+ assertEquals(1, namesToMBEs.get("impl").getRuntimeBeans().iterator().next().getAttributes().size());
+ }
+
protected RuntimeBeanEntry findFirstByYangName(
Collection<RuntimeBeanEntry> runtimeBeans, String yangName) {
for (RuntimeBeanEntry rb : runtimeBeans) {
private void assertMatches(String prefix, String input) {
RevisionAwareXPath whenConstraint = mock(RevisionAwareXPath.class);
doReturn(input).when(whenConstraint).toString();
- Matcher output = ModuleMXBeanEntry.getWhenConditionMatcher(prefix,
+ Matcher output = ModuleMXBeanEntryBuilder.getWhenConditionMatcher(prefix,
whenConstraint);
assertTrue(output.matches());
assertEquals("threadpool-dynamic", output.group(1));