Search in sources :

Example 1 with AncestorAttributeResolver

use of org.apache.qpid.server.model.AncestorAttributeResolver in project qpid-broker-j by apache.

the class AncestorAttributeResolverTest method testResolveToSelf.

public void testResolveToSelf() throws Exception {
    _ancestorAttributeResolver = new AncestorAttributeResolver(_car);
    String actual = _ancestorAttributeResolver.resolve("ancestor:testcar:name", null);
    assertEquals(CAR_NAME, actual);
}
Also used : AncestorAttributeResolver(org.apache.qpid.server.model.AncestorAttributeResolver)

Example 2 with AncestorAttributeResolver

use of org.apache.qpid.server.model.AncestorAttributeResolver in project qpid-broker-j by apache.

the class AncestorAttributeResolverTest method testResolveAncestorAttributeOfTypeConfiguredObject.

public void testResolveAncestorAttributeOfTypeConfiguredObject() throws Exception {
    Map<String, Object> carAttributes = new HashMap<>();
    carAttributes.put(ConfiguredObject.NAME, CAR_NAME);
    carAttributes.put(ConfiguredObject.TYPE, TestKitCarImpl.TEST_KITCAR_TYPE);
    carAttributes.put("alternateEngine", _engine);
    _car = _model.getObjectFactory().create(TestCar.class, carAttributes, null);
    _ancestorAttributeResolver = new AncestorAttributeResolver(_car);
    String actual = _ancestorAttributeResolver.resolve("ancestor:testcar:alternateEngine", null);
    assertEquals("Unexpected resolved ancestor attribute of type ConfiguredObject", _engine.getId().toString(), actual);
}
Also used : HashMap(java.util.HashMap) AncestorAttributeResolver(org.apache.qpid.server.model.AncestorAttributeResolver) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject)

Example 3 with AncestorAttributeResolver

use of org.apache.qpid.server.model.AncestorAttributeResolver in project qpid-broker-j by apache.

the class AncestorAttributeResolverTest method testResolveToParent.

public void testResolveToParent() throws Exception {
    _ancestorAttributeResolver = new AncestorAttributeResolver(_engine);
    String actual = _ancestorAttributeResolver.resolve("ancestor:testcar:name", null);
    assertEquals(CAR_NAME, actual);
}
Also used : AncestorAttributeResolver(org.apache.qpid.server.model.AncestorAttributeResolver)

Example 4 with AncestorAttributeResolver

use of org.apache.qpid.server.model.AncestorAttributeResolver in project qpid-broker-j by apache.

the class AncestorAttributeResolverTest method testUnrecognisedCategoryName.

public void testUnrecognisedCategoryName() throws Exception {
    _ancestorAttributeResolver = new AncestorAttributeResolver(_car);
    String actual = _ancestorAttributeResolver.resolve("ancestor:notacategoty:name", null);
    assertNull(actual);
}
Also used : AncestorAttributeResolver(org.apache.qpid.server.model.AncestorAttributeResolver)

Example 5 with AncestorAttributeResolver

use of org.apache.qpid.server.model.AncestorAttributeResolver in project qpid-broker-j by apache.

the class AncestorAttributeResolverTest method testResolveAncestorAttributeOfTypeMap.

public void testResolveAncestorAttributeOfTypeMap() throws Exception {
    Map<String, Object> carAttributes = new HashMap<>();
    carAttributes.put(ConfiguredObject.NAME, CAR_NAME);
    carAttributes.put(ConfiguredObject.TYPE, TestKitCarImpl.TEST_KITCAR_TYPE);
    Map<String, Object> parameters = new HashMap<>();
    parameters.put("int", 1);
    parameters.put("string", "value");
    carAttributes.put("parameters", parameters);
    _car = _model.getObjectFactory().create(TestCar.class, carAttributes, null);
    _ancestorAttributeResolver = new AncestorAttributeResolver(_car);
    String actual = _ancestorAttributeResolver.resolve("ancestor:testcar:parameters", null);
    ObjectMapper objectMapper = new ObjectMapper();
    Map<Object, Object> data = objectMapper.readValue(actual, HashMap.class);
    assertEquals("Unexpected resolved ancestor attribute of type Map", parameters, data);
}
Also used : HashMap(java.util.HashMap) AncestorAttributeResolver(org.apache.qpid.server.model.AncestorAttributeResolver) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

AncestorAttributeResolver (org.apache.qpid.server.model.AncestorAttributeResolver)7 HashMap (java.util.HashMap)2 ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1