Search in sources :

Example 36 with LegacyConfiguredObject

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

the class LatestManagementControllerAdapterTest method handlePut.

@Test
public void handlePut() throws Exception {
    final String hostName = "test";
    final String queueName = "foo";
    final QueueManagingVirtualHost<?> virtualHost = createTestVirtualHost(hostName);
    final String nodeName = virtualHost.getParent().getName();
    final Broker root = virtualHost.getBroker();
    final ManagementRequest request = mockManagementRequest(root, "PUT", "queue", Arrays.asList(nodeName, hostName), Collections.emptyMap());
    when(request.getBody(LinkedHashMap.class)).thenReturn(new LinkedHashMap<String, Object>(Collections.singletonMap("name", queueName)));
    when(request.getRequestURL()).thenReturn("test");
    final ManagementResponse response = _adapter.handlePut(request);
    assertThat(response, is(notNullValue()));
    assertThat(response.getResponseCode(), is(equalTo(201)));
    assertThat(response.getBody(), is(notNullValue()));
    assertThat(response.getBody(), is(instanceOf(LegacyConfiguredObject.class)));
    final LegacyConfiguredObject object = (LegacyConfiguredObject) response.getBody();
    assertThat(object.getAttribute(LegacyConfiguredObject.NAME), is(equalTo("foo")));
}
Also used : ManagementRequest(org.apache.qpid.server.management.plugin.ManagementRequest) LegacyConfiguredObject(org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject) Broker(org.apache.qpid.server.model.Broker) ManagementResponse(org.apache.qpid.server.management.plugin.ManagementResponse) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) LegacyConfiguredObject(org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject) Test(org.junit.Test)

Example 37 with LegacyConfiguredObject

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

the class DestinationController method findExchange.

private LegacyConfiguredObject findExchange(final ConfiguredObject<?> root, final List<String> path, final Predicate<LegacyConfiguredObject> predicate) {
    final Collection<String> hierarchy = getNextVersionManagementController().getCategoryHierarchy(root, ExchangeController.TYPE);
    final List<String> exchangePath = path.size() > hierarchy.size() - 1 ? path.subList(0, hierarchy.size() - 1) : path;
    final Object result = getNextVersionManagementController().get(root, ExchangeController.TYPE, exchangePath, Collections.emptyMap());
    if (result instanceof Collection) {
        final Collection<?> exchanges = (Collection<?>) result;
        return exchanges.stream().filter(LegacyConfiguredObject.class::isInstance).map(LegacyConfiguredObject.class::cast).filter(predicate).findFirst().orElse(null);
    } else {
        throw createBadRequestManagementException("Cannot find alternate exchange");
    }
}
Also used : GenericLegacyConfiguredObject(org.apache.qpid.server.management.plugin.controller.GenericLegacyConfiguredObject) LegacyConfiguredObject(org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject) Collection(java.util.Collection) GenericLegacyConfiguredObject(org.apache.qpid.server.management.plugin.controller.GenericLegacyConfiguredObject) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) LegacyConfiguredObject(org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject)

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