use of org.apache.qpid.server.model.ConfiguredObject in project qpid-broker-j by apache.
the class ConfiguredObjectQueryTest method testNoClauses_SingleResult.
public void testNoClauses_SingleResult() {
final UUID objectUuid = UUID.randomUUID();
final String objectName = "obj1";
ConfiguredObject obj1 = createCO(new HashMap<String, Object>() {
{
put(ConfiguredObject.ID, objectUuid);
put(ConfiguredObject.NAME, objectName);
}
});
_objects.add(obj1);
_query = new ConfiguredObjectQuery(_objects, null, null);
final List<String> headers = _query.getHeaders();
assertEquals("Unexpected headers", Lists.newArrayList(ConfiguredObject.ID, ConfiguredObject.NAME), headers);
List<List<Object>> results = _query.getResults();
assertEquals("Unexpected number of results", 1, results.size());
List<Object> row = results.iterator().next();
assertEquals("Unexpected row", Lists.newArrayList(objectUuid, objectName), row);
}
use of org.apache.qpid.server.model.ConfiguredObject in project qpid-broker-j by apache.
the class ConfiguredObjectQueryTest method testLimitWithoutOffset.
public void testLimitWithoutOffset() {
int numberOfTestObjects = 3;
for (int i = 0; i < numberOfTestObjects; i++) {
final String name = "test-" + i;
ConfiguredObject object = createCO(new HashMap<String, Object>() {
{
put("name", name);
}
});
_objects.add(object);
}
_query = new ConfiguredObjectQuery(_objects, "name", null, "name", "1", "0");
assertQueryResults(new Object[][] { { "test-0" } }, _query.getResults());
_query = new ConfiguredObjectQuery(_objects, "name", null, "name", "1", "1");
assertQueryResults(new Object[][] { { "test-1" } }, _query.getResults());
_query = new ConfiguredObjectQuery(_objects, "name", null, "name", "1", "3");
assertQueryResults(new Object[0][1], _query.getResults());
_query = new ConfiguredObjectQuery(_objects, "name", null, "name", "-1", "1");
assertQueryResults(new Object[][] { { "test-1" }, { "test-2" } }, _query.getResults());
_query = new ConfiguredObjectQuery(_objects, "name", null, "name", "-1", "-4");
assertQueryResults(new Object[][] { { "test-0" }, { "test-1" }, { "test-2" } }, _query.getResults());
_query = new ConfiguredObjectQuery(_objects, "name", null, "name", "-1", "-2");
assertQueryResults(new Object[][] { { "test-1" }, { "test-2" } }, _query.getResults());
_query = new ConfiguredObjectQuery(_objects, "name", null, "name", "invalidLimit", "invalidOffset");
assertQueryResults(new Object[][] { { "test-0" }, { "test-1" }, { "test-2" } }, _query.getResults());
_query = new ConfiguredObjectQuery(_objects, "name", null, "name", null, null);
assertQueryResults(new Object[][] { { "test-0" }, { "test-1" }, { "test-2" } }, _query.getResults());
}
use of org.apache.qpid.server.model.ConfiguredObject in project qpid-broker-j by apache.
the class ConfiguredObjectQueryTest method testSingleOrderByClause.
public void testSingleOrderByClause() {
final int NUMBER_OF_OBJECTS = 3;
for (int i = 0; i < NUMBER_OF_OBJECTS; ++i) {
final int foo = (i + 1) % NUMBER_OF_OBJECTS;
ConfiguredObject object = createCO(new HashMap<String, Object>() {
{
put("foo", foo);
}
});
_objects.add(object);
}
ConfiguredObject object = createCO(new HashMap<String, Object>() {
{
put("foo", null);
}
});
_objects.add(object);
List<List<Object>> results;
_query = new ConfiguredObjectQuery(_objects, "foo", null, "foo ASC");
results = _query.getResults();
assertQueryResults(new Object[][] { { null }, { 0 }, { 1 }, { 2 } }, results);
_query = new ConfiguredObjectQuery(_objects, "foo", null, "foo DESC");
results = _query.getResults();
assertQueryResults(new Object[][] { { 2 }, { 1 }, { 0 }, { null } }, results);
// if not specified order should be ASC
_query = new ConfiguredObjectQuery(_objects, "foo", null, "foo");
results = _query.getResults();
assertQueryResults(new Object[][] { { null }, { 0 }, { 1 }, { 2 } }, results);
}
use of org.apache.qpid.server.model.ConfiguredObject in project qpid-broker-j by apache.
the class ConfiguredObjectQueryTest method testNoClauses_TwoResult.
public void testNoClauses_TwoResult() {
final UUID object1Uuid = UUID.randomUUID();
final String object1Name = "obj1";
final UUID object2Uuid = UUID.randomUUID();
final String object2Name = "obj2";
ConfiguredObject obj1 = createCO(new HashMap<String, Object>() {
{
put(ConfiguredObject.ID, object1Uuid);
put(ConfiguredObject.NAME, object1Name);
put("foo", "bar");
}
});
ConfiguredObject obj2 = createCO(new HashMap<String, Object>() {
{
put(ConfiguredObject.ID, object2Uuid);
put(ConfiguredObject.NAME, object2Name);
}
});
_objects.add(obj1);
_objects.add(obj2);
_query = new ConfiguredObjectQuery(_objects, null, null);
List<List<Object>> results = _query.getResults();
assertEquals("Unexpected number of results", 2, results.size());
final Iterator<List<Object>> iterator = results.iterator();
List<Object> row1 = iterator.next();
assertEquals("Unexpected row", Lists.newArrayList(object1Uuid, object1Name), row1);
List<Object> row2 = iterator.next();
assertEquals("Unexpected row", Lists.newArrayList(object2Uuid, object2Name), row2);
}
use of org.apache.qpid.server.model.ConfiguredObject in project qpid-broker-j by apache.
the class ConfiguredObjectQueryTest method testSelectClause_NonExistingColumn.
public void testSelectClause_NonExistingColumn() {
ConfiguredObject obj = createCO(new HashMap<String, Object>() {
{
put(ConfiguredObject.ID, UUID.randomUUID());
}
});
_objects.add(obj);
_query = new ConfiguredObjectQuery(_objects, "foo", null);
List<List<Object>> results = _query.getResults();
assertEquals("Unexpected number of results", 1, results.size());
assertEquals("Unexpected headers", Collections.singletonList("foo"), _query.getHeaders());
assertEquals("Unexpected row", Collections.singletonList(null), results.get(0));
}
Aggregations