Search in sources :

Example 31 with LegacyConfiguredObject

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

the class VirtualHostControllerTest method convertNextVersionLegacyConfiguredObject.

@Test
public void convertNextVersionLegacyConfiguredObject() {
    final LegacyConfiguredObject nextVersionVirtualHost = mock(LegacyConfiguredObject.class);
    when(nextVersionVirtualHost.getAttribute(LegacyConfiguredObject.NAME)).thenReturn("test");
    final LegacyConfiguredObject converted = _virtualHostController.convertNextVersionLegacyConfiguredObject(nextVersionVirtualHost);
    assertThat(converted, is(notNullValue()));
    assertThat(converted.getCategory(), is(equalTo(VirtualHostController.TYPE)));
    assertThat(converted.getAttribute(LegacyConfiguredObject.NAME), is(equalTo("test")));
    assertThat(converted.getAttribute("modelVersion"), is(equalTo("6.1")));
    assertThat(converted.getAttribute("queue_deadLetterQueueEnabled"), is(equalTo(false)));
}
Also used : LegacyConfiguredObject(org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject) Test(org.junit.Test)

Example 32 with LegacyConfiguredObject

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

the class ContainerControllerTest method convertNextVersionBrokerConfiguredObject.

@Test
public void convertNextVersionBrokerConfiguredObject() {
    final CategoryController controller = _factory.createController("Broker", _nextVersionManagementController);
    assertThat(controller.getCategory(), is(equalTo("Broker")));
    final LegacyConfiguredObject object = mock(LegacyConfiguredObject.class);
    when(object.getAttribute("modelVersion")).thenReturn("foo");
    final LegacyConfiguredObject converted = controller.convertFromNextVersion(object);
    Object modelVersion = converted.getAttribute("modelVersion");
    assertThat(modelVersion, is(equalTo(MODEL_VERSION)));
}
Also used : LegacyConfiguredObject(org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject) LegacyConfiguredObject(org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject) CategoryController(org.apache.qpid.server.management.plugin.controller.CategoryController) Test(org.junit.Test)

Example 33 with LegacyConfiguredObject

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

the class ContainerControllerTest method convertNextVersionVirtualHostConfiguredObject.

@Test
public void convertNextVersionVirtualHostConfiguredObject() {
    final CategoryController controller = _factory.createController("VirtualHost", _nextVersionManagementController);
    assertThat(controller.getCategory(), is(equalTo("VirtualHost")));
    final LegacyConfiguredObject object = mock(LegacyConfiguredObject.class);
    when(object.getAttribute("modelVersion")).thenReturn("foo");
    final LegacyConfiguredObject converted = controller.convertFromNextVersion(object);
    Object modelVersion = converted.getAttribute("modelVersion");
    assertThat(modelVersion, is(equalTo(MODEL_VERSION)));
}
Also used : LegacyConfiguredObject(org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject) LegacyConfiguredObject(org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject) CategoryController(org.apache.qpid.server.management.plugin.controller.CategoryController) Test(org.junit.Test)

Example 34 with LegacyConfiguredObject

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

the class LatestManagementControllerAdapterTest method handleGet.

@Test
public void handleGet() throws Exception {
    final String hostName = "test";
    final String queueName = "foo";
    final QueueManagingVirtualHost<?> virtualHost = createTestVirtualHost(hostName);
    virtualHost.createChild(Queue.class, Collections.singletonMap(Queue.NAME, queueName));
    final String nodeName = virtualHost.getParent().getName();
    final ManagementRequest request = mockManagementRequest(virtualHost.getBroker(), "GET", "queue", Arrays.asList(nodeName, hostName), Collections.singletonMap("name", Collections.singletonList("foo")));
    final ManagementResponse response = _adapter.handleGet(request);
    assertThat(response, is(notNullValue()));
    assertThat(response.getResponseCode(), is(equalTo(200)));
    assertThat(response.getBody(), is(notNullValue()));
    assertThat(response.getBody(), is(instanceOf(Collection.class)));
    final Collection data = (Collection) response.getBody();
    assertThat(data.size(), is(equalTo(1)));
    final Object object = data.iterator().next();
    assertThat(object, is(notNullValue()));
    assertThat(object, is(instanceOf(LegacyConfiguredObject.class)));
    assertThat(((LegacyConfiguredObject) object).getAttribute(LegacyConfiguredObject.NAME), is(equalTo("foo")));
}
Also used : ManagementRequest(org.apache.qpid.server.management.plugin.ManagementRequest) ManagementResponse(org.apache.qpid.server.management.plugin.ManagementResponse) Collection(java.util.Collection) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) LegacyConfiguredObject(org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject) Test(org.junit.Test)

Example 35 with LegacyConfiguredObject

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

the class LatestManagementControllerAdapterTest method createOrUpdate.

@Test
public void createOrUpdate() 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, "POST", "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 Object response = _adapter.createOrUpdate(virtualHost.getBroker(), "queue", Arrays.asList(nodeName, hostName), Collections.singletonMap("name", queueName), true);
    assertThat(response, is(instanceOf(LegacyConfiguredObject.class)));
    final LegacyConfiguredObject object = (LegacyConfiguredObject) response;
    assertThat(object.getAttribute(LegacyConfiguredObject.NAME), is(equalTo(queueName)));
}
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) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) LegacyConfiguredObject(org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject) 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