use of org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject in project qpid-broker-j by apache.
the class DestinationControllerTest method convertAttributesToNextVersion.
@Test
public void convertAttributesToNextVersion() {
final String alternateExchangeName = "alternate";
final String queueName = "test";
final Map<String, Object> attributes = new HashMap<>();
attributes.put("alternateExchange", alternateExchangeName);
attributes.put(LegacyConfiguredObject.NAME, queueName);
final DestinationController controller = new DestinationController(_legacyVersionManagementController, "Queue", new String[] { "VirtualHost" }, null, Collections.emptySet());
assertThat(controller.getCategory(), is(equalTo("Queue")));
assertThat(controller.getParentCategories(), is(equalTo(new String[] { "VirtualHost" })));
final ConfiguredObject root = mock(ConfiguredObject.class);
final List<String> exchangePath = Arrays.asList("vhn", "vh");
final LegacyConfiguredObject exchange = mock(LegacyConfiguredObject.class);
when(exchange.getAttribute(LegacyConfiguredObject.NAME)).thenReturn(alternateExchangeName);
when(exchange.getCategory()).thenReturn(ExchangeController.TYPE);
final Collection<LegacyConfiguredObject> exchanges = Collections.singletonList(exchange);
when(_nextVersionManagementController.get(eq(root), eq(ExchangeController.TYPE), eq(exchangePath), eq(Collections.emptyMap()))).thenReturn(exchanges);
final Collection<String> hierarchy = Arrays.asList("virtualhostnode", "virtualhost", "exchange");
when(_nextVersionManagementController.getCategoryHierarchy(eq(root), eq(ExchangeController.TYPE))).thenReturn(hierarchy);
final List<String> path = Arrays.asList("vhn", "vh", queueName);
final Map<String, Object> converted = controller.convertAttributesToNextVersion(root, path, attributes);
assertThat(converted.size(), is(equalTo(2)));
assertThat(converted.get(LegacyConfiguredObject.NAME), is(equalTo(queueName)));
final Object alternateBinding = converted.get("alternateBinding");
assertThat(alternateBinding, is(notNullValue()));
assertThat(alternateBinding, is(instanceOf(Map.class)));
final Map<?, ?> alternateDestination = (Map<?, ?>) alternateBinding;
assertThat(alternateDestination.get("destination"), is(equalTo(alternateExchangeName)));
assertThat(alternateDestination.get("attributes"), is(equalTo(null)));
}
use of org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject in project qpid-broker-j by apache.
the class DestinationControllerTest method testLegacyDestination.
@Test
public void testLegacyDestination() {
final String alternateExchangeName = "alt";
final LegacyConfiguredObject nextVersionDestination = mock(LegacyConfiguredObject.class);
final AlternateBinding alternateDestination = mock(AlternateBinding.class);
when(alternateDestination.getDestination()).thenReturn(alternateExchangeName);
when(nextVersionDestination.getAttribute("alternateBinding")).thenReturn(alternateDestination);
final LegacyConfiguredObject vh = mock(LegacyConfiguredObject.class);
when(nextVersionDestination.getParent(VirtualHostController.TYPE)).thenReturn(vh);
final LegacyConfiguredObject alternateExchange = mock(LegacyConfiguredObject.class);
when(alternateExchange.getCategory()).thenReturn(ExchangeController.TYPE);
when(alternateExchange.getAttribute(LegacyConfiguredObject.NAME)).thenReturn(alternateExchangeName);
final Collection<LegacyConfiguredObject> exchanges = Collections.singletonList(alternateExchange);
when(vh.getChildren(ExchangeController.TYPE)).thenReturn(exchanges);
final LegacyConfiguredObject converted = mock(LegacyConfiguredObject.class);
when(_legacyVersionManagementController.convertFromNextVersion(alternateExchange)).thenReturn(converted);
DestinationController.LegacyDestination destination = new DestinationController.LegacyDestination(_legacyVersionManagementController, nextVersionDestination, "Queue");
assertThat(destination.getAttribute("alternateExchange"), is(equalTo(converted)));
}
use of org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject in project qpid-broker-j by apache.
the class SessionControllerTest method convertNextVersionLegacyConfiguredObject.
@Test
public void convertNextVersionLegacyConfiguredObject() {
final UUID sessionID = UUID.randomUUID();
final LegacyConfiguredObject nextVersionSession = mock(LegacyConfiguredObject.class);
final LegacyConfiguredObject nextVersionConsumer = mock(LegacyConfiguredObject.class);
when(nextVersionSession.getCategory()).thenReturn(SessionController.TYPE);
when(nextVersionSession.getAttribute(LegacyConfiguredObject.ID)).thenReturn(sessionID);
final ManagementResponse operationResult = new ControllerManagementResponse(ResponseType.MODEL_OBJECT, Collections.singletonList(nextVersionConsumer));
when(nextVersionSession.invoke(eq("getConsumers"), eq(Collections.emptyMap()), eq(true))).thenReturn(operationResult);
final LegacyConfiguredObject convertedConsumer = mock(LegacyConfiguredObject.class);
when(_legacyManagementController.convertFromNextVersion(nextVersionConsumer)).thenReturn(convertedConsumer);
final LegacyConfiguredObject convertedSession = _sessionController.convertNextVersionLegacyConfiguredObject(nextVersionSession);
assertThat(convertedSession.getAttribute(LegacyConfiguredObject.ID), is(equalTo(sessionID)));
final Collection<LegacyConfiguredObject> consumers = convertedSession.getChildren(ConsumerController.TYPE);
assertThat(consumers, is(notNullValue()));
assertThat(consumers.size(), is(equalTo(1)));
assertThat(consumers.iterator().next(), is(equalTo(convertedConsumer)));
}
use of org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject in project qpid-broker-j by apache.
the class LegacyManagementControllerTest method formatConfiguredObject.
@Test
public void formatConfiguredObject() {
final String objectName = "test-object";
final String hostName = "test-vhn";
final Map<String, List<String>> parameters = Collections.singletonMap("depth", Collections.singletonList("1"));
final LegacyConfiguredObject object = mock(LegacyConfiguredObject.class);
final LegacyConfiguredObject vhn = mock(LegacyConfiguredObject.class);
when(object.getAttributeNames()).thenReturn(Arrays.asList(LegacyConfiguredObject.NAME, LegacyConfiguredObject.TYPE));
when(object.getAttribute(LegacyConfiguredObject.NAME)).thenReturn(objectName);
when(object.getAttribute(LegacyConfiguredObject.TYPE)).thenReturn("Broker");
when(object.getCategory()).thenReturn("Broker");
when(object.getChildren("VirtualHostNode")).thenReturn(Collections.singletonList(vhn));
when(vhn.getAttributeNames()).thenReturn(Arrays.asList(LegacyConfiguredObject.NAME, LegacyConfiguredObject.TYPE));
when(vhn.getAttribute(LegacyConfiguredObject.NAME)).thenReturn(hostName);
when(vhn.getAttribute(LegacyConfiguredObject.TYPE)).thenReturn("VirtualHostNode");
when(vhn.getCategory()).thenReturn("VirtualHostNode");
Object data = _controller.formatConfiguredObject(object, parameters, true);
assertThat(data, is(instanceOf(Map.class)));
Map<?, ?> formatted = (Map<?, ?>) data;
assertThat(formatted.get(LegacyConfiguredObject.NAME), is(equalTo(objectName)));
assertThat(formatted.get(LegacyConfiguredObject.TYPE), is(equalTo("Broker")));
Object vhns = formatted.get("virtualhostnodes");
assertThat(vhns, is(instanceOf(Collection.class)));
Collection<?> nodes = (Collection<?>) vhns;
assertThat(nodes.size(), is(equalTo(1)));
Object node = nodes.iterator().next();
assertThat(node, is(instanceOf(Map.class)));
Map<?, ?> formattedNode = (Map<?, ?>) node;
assertThat(formattedNode.get(LegacyConfiguredObject.NAME), is(equalTo(hostName)));
assertThat(formattedNode.get(LegacyConfiguredObject.TYPE), is(equalTo("VirtualHostNode")));
}
use of org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject in project qpid-broker-j by apache.
the class LegacyCategoryController_v8_0Test method createNewVersionPortMock.
private LegacyConfiguredObject createNewVersionPortMock() {
final LegacyConfiguredObject nextVersionPort = mock(LegacyConfiguredObject.class);
final Map<String, String> newVersionContext = new HashMap<>();
newVersionContext.put(NEW_CONTEXT_TLS_PROTOCOL_ALLOW_LIST, PROTOCOL_ALLOW_LIST);
newVersionContext.put(NEW_CONTEXT_TLS_PROTOCOL_DENY_LIST, PROTOCOL_DENY_LIST);
when(nextVersionPort.getAttribute(ATTRIBUTE_NAME)).thenReturn(PORT_NAME);
when(nextVersionPort.getAttribute(ATTRIBUTE_CONTEXT)).thenReturn(newVersionContext);
when(nextVersionPort.getContextValue(NEW_CONTEXT_TLS_PROTOCOL_ALLOW_LIST)).thenReturn(PROTOCOL_ALLOW_LIST);
when(nextVersionPort.getContextValue(NEW_CONTEXT_TLS_PROTOCOL_DENY_LIST)).thenReturn(PROTOCOL_DENY_LIST);
return nextVersionPort;
}
Aggregations