Search in sources :

Example 1 with TestEngine

use of org.apache.qpid.server.model.testmodels.hierarchy.TestEngine in project qpid-broker-j by apache.

the class ConfiguredObjectToMapConverterTest method testExcludeInheritedContextAndActual.

public void testExcludeInheritedContextAndActual() {
    TestEngine engine = createEngineWithContext();
    ConfiguredObjectToMapConverter.ConverterOptions options = new ConfiguredObjectToMapConverter.ConverterOptions(1, true, 0, false, true);
    Map<String, Object> resultMap = _converter.convertObjectToMap(engine, TestEngine.class, options);
    Map<String, String> context = getContext(resultMap);
    assertEquals("Unexpected size of context", 1, context.size());
    assertEquals("Unexpected context content", CHILD_CONTEXT_PROPERTY_ACTUAL_VALUE, context.get(CHILD_CONTEXT_PROPERTY_NAME));
}
Also used : ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) TestEngine(org.apache.qpid.server.model.testmodels.hierarchy.TestEngine)

Example 2 with TestEngine

use of org.apache.qpid.server.model.testmodels.hierarchy.TestEngine in project qpid-broker-j by apache.

the class ConfiguredObjectToMapConverterTest method createEngineWithContext.

private TestEngine createEngineWithContext() {
    setTestSystemProperty(TEST_SYSTEM_PROPERTY1_NAME, TEST_SYSTEM_PROPERTY1_ACTUAL_VALUE);
    setTestSystemProperty(TEST_SYSTEM_PROPERTY2_NAME, TEST_SYSTEM_PROPERTY2_ACTUAL_VALUE);
    Model model = org.apache.qpid.server.model.testmodels.hierarchy.TestModel.getInstance();
    final Map<String, Object> carAttributes = new HashMap<>();
    carAttributes.put(ConfiguredObject.NAME, "myCar");
    Map<String, String> carContext = new HashMap<>();
    carContext.put(PARENT_CONTEXT_PROPERTY1_NAME, PARENT_CONTEXT_PROPERTY1_ACTUAL_VALUE);
    carContext.put(PARENT_CONTEXT_PROPERTY2_NAME, PARENT_CONTEXT_PROPERTY2_ACTUAL_VALUE);
    carAttributes.put(ConfiguredObject.CONTEXT, carContext);
    TestCar car = model.getObjectFactory().create(TestCar.class, carAttributes, null);
    final Map<String, Object> engineAttributes = new HashMap<>();
    engineAttributes.put(ConfiguredObject.NAME, "myEngine");
    engineAttributes.put(ConfiguredObject.TYPE, TestElecEngineImpl.TEST_ELEC_ENGINE_TYPE);
    Map<String, String> engineContext = new HashMap<>();
    engineContext.put(CHILD_CONTEXT_PROPERTY_NAME, CHILD_CONTEXT_PROPERTY_ACTUAL_VALUE);
    engineAttributes.put(ConfiguredObject.CONTEXT, engineContext);
    return (TestEngine) car.createChild(TestEngine.class, engineAttributes);
}
Also used : HashMap(java.util.HashMap) Model(org.apache.qpid.server.model.Model) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) TestEngine(org.apache.qpid.server.model.testmodels.hierarchy.TestEngine) TestCar(org.apache.qpid.server.model.testmodels.hierarchy.TestCar)

Example 3 with TestEngine

use of org.apache.qpid.server.model.testmodels.hierarchy.TestEngine in project qpid-broker-j by apache.

the class ConfiguredObjectToMapConverterTest method testIncludeInheritedContextAndEffective.

public void testIncludeInheritedContextAndEffective() {
    TestEngine engine = createEngineWithContext();
    ConfiguredObjectToMapConverter.ConverterOptions options = new ConfiguredObjectToMapConverter.ConverterOptions(1, false, 0, false, false);
    Map<String, Object> resultMap = _converter.convertObjectToMap(engine, TestEngine.class, options);
    Map<String, String> context = getContext(resultMap);
    assertTrue("Unexpected size of context", context.size() >= 5);
    assertEquals("Unexpected engine context content", CHILD_CONTEXT_PROPERTY_EFFECTIVE_VALUE, context.get(CHILD_CONTEXT_PROPERTY_NAME));
    assertEquals("Unexpected car context content", PARENT_CONTEXT_PROPERTY1_ACTUAL_VALUE, context.get(PARENT_CONTEXT_PROPERTY1_NAME));
    assertEquals("Unexpected car context content", PARENT_CONTEXT_PROPERTY2_EFFECTIVE_VALUE, context.get(PARENT_CONTEXT_PROPERTY2_NAME));
    assertEquals("Unexpected system context content", TEST_SYSTEM_PROPERTY1_ACTUAL_VALUE, context.get(TEST_SYSTEM_PROPERTY1_NAME));
    assertEquals("Unexpected system context content", TEST_SYSTEM_PROPERTY2_EFFECTIVE_VALUE, context.get(TEST_SYSTEM_PROPERTY2_NAME));
}
Also used : ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) TestEngine(org.apache.qpid.server.model.testmodels.hierarchy.TestEngine)

Example 4 with TestEngine

use of org.apache.qpid.server.model.testmodels.hierarchy.TestEngine in project qpid-broker-j by apache.

the class ConfiguredObjectToMapConverterTest method testIncludeInheritedContextAndActual.

public void testIncludeInheritedContextAndActual() {
    TestEngine engine = createEngineWithContext();
    ConfiguredObjectToMapConverter.ConverterOptions options = new ConfiguredObjectToMapConverter.ConverterOptions(1, true, 0, false, false);
    Map<String, Object> resultMap = _converter.convertObjectToMap(engine, TestEngine.class, options);
    Map<String, String> context = getContext(resultMap);
    assertTrue("Unexpected size of context", context.size() >= 5);
    assertEquals("Unexpected engine context content", CHILD_CONTEXT_PROPERTY_ACTUAL_VALUE, context.get(CHILD_CONTEXT_PROPERTY_NAME));
    assertEquals("Unexpected car context content", PARENT_CONTEXT_PROPERTY1_ACTUAL_VALUE, context.get(PARENT_CONTEXT_PROPERTY1_NAME));
    assertEquals("Unexpected car context content", PARENT_CONTEXT_PROPERTY2_ACTUAL_VALUE, context.get(PARENT_CONTEXT_PROPERTY2_NAME));
    assertEquals("Unexpected system context content", TEST_SYSTEM_PROPERTY1_ACTUAL_VALUE, context.get(TEST_SYSTEM_PROPERTY1_NAME));
    assertEquals("Unexpected system context content", TEST_SYSTEM_PROPERTY2_ACTUAL_VALUE, context.get(TEST_SYSTEM_PROPERTY2_NAME));
}
Also used : ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) TestEngine(org.apache.qpid.server.model.testmodels.hierarchy.TestEngine)

Example 5 with TestEngine

use of org.apache.qpid.server.model.testmodels.hierarchy.TestEngine in project qpid-broker-j by apache.

the class ConfiguredObjectToMapConverterTest method testExcludeInheritedContextAndEffective.

public void testExcludeInheritedContextAndEffective() {
    TestEngine engine = createEngineWithContext();
    ConfiguredObjectToMapConverter.ConverterOptions options = new ConfiguredObjectToMapConverter.ConverterOptions(1, false, 0, false, true);
    Map<String, Object> resultMap = _converter.convertObjectToMap(engine, TestEngine.class, options);
    Map<String, String> context = getContext(resultMap);
    assertEquals("Unexpected size of context", 1, context.size());
    assertEquals("Unexpected context content", CHILD_CONTEXT_PROPERTY_EFFECTIVE_VALUE, context.get(CHILD_CONTEXT_PROPERTY_NAME));
}
Also used : ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) TestEngine(org.apache.qpid.server.model.testmodels.hierarchy.TestEngine)

Aggregations

ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)5 TestEngine (org.apache.qpid.server.model.testmodels.hierarchy.TestEngine)5 HashMap (java.util.HashMap)1 Model (org.apache.qpid.server.model.Model)1 TestCar (org.apache.qpid.server.model.testmodels.hierarchy.TestCar)1