Search in sources :

Example 6 with LegacyConfiguredObject

use of org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject in project qpid-broker-j by apache.

the class LegacyManagementControllerTest method get.

@Test
public void get() {
    final List<String> path = Collections.emptyList();
    final LegacyConfiguredObject object = mock(LegacyConfiguredObject.class);
    final Map<String, List<String>> parameters = Collections.emptyMap();
    final ConfiguredObject<?> root = mock(ConfiguredObject.class);
    when(_nextVersionManagementController.get(eq(root), eq(BrokerController.TYPE), eq(path), any())).thenReturn(object);
    final Object result = _controller.get(root, BrokerController.TYPE, path, parameters);
    assertThat(result, is(instanceOf(Collection.class)));
    Collection data = (Collection) result;
    assertThat(data.size(), is(equalTo(1)));
    Object obj = data.iterator().next();
    assertThat(obj, is(instanceOf(LegacyConfiguredObject.class)));
    assertThat(((LegacyConfiguredObject) obj).getCategory(), is(equalTo(BrokerController.TYPE)));
}
Also used : LegacyConfiguredObject(org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject) Collection(java.util.Collection) List(java.util.List) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) LegacyConfiguredObject(org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject) Test(org.junit.Test)

Example 7 with LegacyConfiguredObject

use of org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject in project qpid-broker-j by apache.

the class BrokerControllerTest method convertNextVersionLegacyConfiguredObject.

@Test
public void convertNextVersionLegacyConfiguredObject() {
    final LegacyConfiguredObject object = mock(LegacyConfiguredObject.class);
    when(object.getAttribute("modelVersion")).thenReturn("foo");
    final Map<String, String> context = new HashMap<>();
    context.put("qpid.port.sessionCountLimit", "512");
    context.put("qpid.port.heartbeatDelay", "10000");
    context.put("qpid.port.closeWhenNoRoute", "true");
    when(object.getAttribute("context")).thenReturn(context);
    final BrokerController controller = new BrokerController(_legacyVersionManagementController, Collections.emptySet());
    assertThat(controller.getCategory(), is(equalTo("Broker")));
    final LegacyConfiguredObject converted = controller.convertFromNextVersion(object);
    assertThat(converted.getAttribute("modelVersion"), is(equalTo(MODEL_VERSION)));
    assertThat(converted.getAttribute("connection.sessionCountLimit"), is(equalTo(512)));
    assertThat(converted.getAttribute("connection.heartBeatDelay"), is(equalTo(10000L)));
    assertThat(converted.getAttribute("connection.closeWhenNoRoute"), is(equalTo(true)));
}
Also used : LegacyConfiguredObject(org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 8 with LegacyConfiguredObject

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)));
}
Also used : LegacyConfiguredObject(org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject) HashMap(java.util.HashMap) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) LegacyConfiguredObject(org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) LegacyConfiguredObject(org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 9 with LegacyConfiguredObject

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)));
}
Also used : LegacyConfiguredObject(org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject) AlternateBinding(org.apache.qpid.server.model.AlternateBinding) Test(org.junit.Test)

Example 10 with LegacyConfiguredObject

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)));
}
Also used : LegacyConfiguredObject(org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject) ControllerManagementResponse(org.apache.qpid.server.management.plugin.controller.ControllerManagementResponse) ManagementResponse(org.apache.qpid.server.management.plugin.ManagementResponse) ControllerManagementResponse(org.apache.qpid.server.management.plugin.controller.ControllerManagementResponse) UUID(java.util.UUID) Test(org.junit.Test)

Aggregations

LegacyConfiguredObject (org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject)37 Test (org.junit.Test)28 ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)22 Collection (java.util.Collection)11 ManagementResponse (org.apache.qpid.server.management.plugin.ManagementResponse)10 HashMap (java.util.HashMap)9 List (java.util.List)7 Map (java.util.Map)7 ControllerManagementResponse (org.apache.qpid.server.management.plugin.controller.ControllerManagementResponse)7 GenericLegacyConfiguredObject (org.apache.qpid.server.management.plugin.controller.GenericLegacyConfiguredObject)6 Binding (org.apache.qpid.server.model.Binding)5 ManagementRequest (org.apache.qpid.server.management.plugin.ManagementRequest)4 LinkedHashMap (java.util.LinkedHashMap)3 CategoryController (org.apache.qpid.server.management.plugin.controller.CategoryController)3 AlternateBinding (org.apache.qpid.server.model.AlternateBinding)3 Broker (org.apache.qpid.server.model.Broker)3 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)3 ArrayList (java.util.ArrayList)2 UUID (java.util.UUID)2 ManagementException (org.apache.qpid.server.management.plugin.ManagementException)2