Search in sources :

Example 76 with ConfiguredObject

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

the class ConfiguredObjectToMapConverterTest method testConfiguredObjectWithSingleConfiguredObjectAttribute.

/*
     * For now, it is the name of the configured object is returned as the attribute value, rather than the
     * configured object itself
     */
@Test
public void testConfiguredObjectWithSingleConfiguredObjectAttribute() throws Exception {
    final String attributeName = "attribute";
    final ConfiguredObject attributeValue = mock(ConfiguredObject.class);
    when(attributeValue.getName()).thenReturn("attributeConfiguredObjectName");
    configureMockToReturnOneAttribute(_configuredObject, attributeName, attributeValue);
    Map<String, Object> resultMap = _converter.convertObjectToMap(_configuredObject, ConfiguredObject.class, new ConfiguredObjectToMapConverter.ConverterOptions(0, false, 120, false, false));
    assertEquals("Unexpected number of attributes", (long) 1, (long) resultMap.size());
    assertEquals("Unexpected attribute value", "attributeConfiguredObjectName", resultMap.get(attributeName));
}
Also used : ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) Test(org.junit.Test)

Example 77 with ConfiguredObject

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

the class ConfiguredObjectQueryTest method testSelectClause_ColumnAliases.

@Test
public void testSelectClause_ColumnAliases() {
    final UUID objectUuid = UUID.randomUUID();
    ConfiguredObject obj = createCO(new HashMap<String, Object>() {

        {
            put(ConfiguredObject.ID, objectUuid);
            put(ConfiguredObject.NAME, "myObj");
            put(NUMBER_ATTR, 1234);
        }
    });
    _objects.add(obj);
    _query = new ConfiguredObjectQuery(_objects, String.format("%s,CONCAT(%s,%s) AS alias", ConfiguredObject.ID, ConfiguredObject.NAME, NUMBER_ATTR), null);
    List<List<Object>> results = _query.getResults();
    assertEquals("Unexpected number of results", (long) 1, (long) results.size());
    final List<String> headers = _query.getHeaders();
    assertEquals("Unexpected headers", Lists.newArrayList(ConfiguredObject.ID, "alias"), headers);
    final Iterator<List<Object>> iterator = results.iterator();
    List<Object> row = iterator.next();
    assertEquals("Unexpected row", Lists.newArrayList(objectUuid, "myObj1234"), row);
}
Also used : ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) ArrayList(java.util.ArrayList) List(java.util.List) UUID(java.util.UUID) Test(org.junit.Test)

Example 78 with ConfiguredObject

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

the class ConfiguredObjectQueryTest method testQuery_DateEquality.

@Test
public void testQuery_DateEquality() {
    final long now = System.currentTimeMillis();
    final ZonedDateTime zonedDateTime = Instant.ofEpochMilli(now).atZone(ZoneId.systemDefault());
    String nowIso8601Str = DateTimeFormatter.ISO_ZONED_DATE_TIME.format(zonedDateTime);
    final UUID objectUuid = UUID.randomUUID();
    ConfiguredObject nonMatch = createCO(new HashMap<String, Object>() {

        {
            put(ConfiguredObject.ID, UUID.randomUUID());
            put(DATE_ATTR, new Date(0));
        }
    });
    ConfiguredObject match = createCO(new HashMap<String, Object>() {

        {
            put(ConfiguredObject.ID, objectUuid);
            put(DATE_ATTR, new Date(now));
        }
    });
    _objects.add(nonMatch);
    _objects.add(match);
    _query = new ConfiguredObjectQuery(_objects, String.format("%s,%s", ConfiguredObject.ID, DATE_ATTR), String.format("%s = TO_DATE('%s')", DATE_ATTR, nowIso8601Str));
    List<List<Object>> results = _query.getResults();
    assertEquals("Unexpected number of results", (long) 1, (long) results.size());
    final Iterator<List<Object>> iterator = results.iterator();
    List<Object> row = iterator.next();
    assertEquals("Unexpected row", objectUuid, row.get(0));
}
Also used : Date(java.util.Date) ZonedDateTime(java.time.ZonedDateTime) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) ArrayList(java.util.ArrayList) List(java.util.List) UUID(java.util.UUID) Test(org.junit.Test)

Example 79 with ConfiguredObject

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

the class QpidCollector method buildLabelValues.

private List<String> buildLabelValues(final ConfiguredObject<?> object) {
    final List<String> labelsValues = new ArrayList<>();
    ConfiguredObject o = object;
    while (o != null && o != _root) {
        labelsValues.add(o.getName());
        o = o.getParent();
    }
    return labelsValues;
}
Also used : ArrayList(java.util.ArrayList) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject)

Example 80 with ConfiguredObject

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

the class PreferenceFactory method fromAttributes.

public static Preference fromAttributes(final ConfiguredObject<?> associatedObject, final Map<String, Object> attributes) {
    final UUID uuid = getId(attributes);
    final String type = getAttributeAsString(Preference.TYPE_ATTRIBUTE, attributes);
    final String name = getAttributeAsString(Preference.NAME_ATTRIBUTE, attributes);
    final String description = getAttributeAsString(Preference.DESCRIPTION_ATTRIBUTE, attributes);
    final Principal owner = getOwner(attributes);
    final Set<Principal> visibilitySet = getVisibilitySet(attributes);
    final Date lastUpdatedDate = getAttributeAsDate(Preference.LAST_UPDATED_DATE_ATTRIBUTE, attributes);
    final Date createdDate = getAttributeAsDate(Preference.CREATED_DATE_ATTRIBUTE, attributes);
    final Map<String, Object> preferenceValueAttributes = getPreferenceValue(attributes);
    PreferenceValue value = convertMapToPreferenceValue(type, preferenceValueAttributes);
    return new PreferenceImpl(associatedObject, uuid, name, type, description, owner, lastUpdatedDate, createdDate, visibilitySet, value);
}
Also used : ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) UUID(java.util.UUID) Principal(java.security.Principal) Date(java.util.Date)

Aggregations

ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)117 ArrayList (java.util.ArrayList)43 HashMap (java.util.HashMap)35 Test (org.junit.Test)33 Map (java.util.Map)29 List (java.util.List)27 LinkedHashMap (java.util.LinkedHashMap)25 UUID (java.util.UUID)21 AbstractConfiguredObject (org.apache.qpid.server.model.AbstractConfiguredObject)21 AbstractConfigurationChangeListener (org.apache.qpid.server.model.AbstractConfigurationChangeListener)15 Collection (java.util.Collection)12 LegacyConfiguredObject (org.apache.qpid.server.management.plugin.controller.LegacyConfiguredObject)12 ConfiguredObjectFinder (org.apache.qpid.server.model.ConfiguredObjectFinder)12 ManagedObject (org.apache.qpid.server.model.ManagedObject)11 State (org.apache.qpid.server.model.State)10 Date (java.util.Date)7 TreeMap (java.util.TreeMap)6 CountDownLatch (java.util.concurrent.CountDownLatch)6 GenericLegacyConfiguredObject (org.apache.qpid.server.management.plugin.controller.GenericLegacyConfiguredObject)6 InternalMessageHeader (org.apache.qpid.server.message.internal.InternalMessageHeader)6