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));
}
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);
}
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));
}
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;
}
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);
}
Aggregations