Search in sources :

Example 1 with StorableTest

use of com.hortonworks.registries.storage.StorableTest in project registry by hortonworks.

the class JdbcStorageManagerIntegrationTest method testSearchQueryApi.

@Test
public void testSearchQueryApi() {
    for (StorableTest storableTest : storableTests) {
        storableTest.addAllToStorage();
        String nameSpace = storableTest.getNameSpace();
        SearchQuery searchQuery = SearchQuery.searchFrom(nameSpace).where(WhereClause.begin().contains("name", "info").and().gt("id", 1L).combine()).orderBy(OrderBy.asc("name"));
        Collection<Storable> storablesWithIdGt1 = getStorageManager().search(searchQuery);
        System.out.println("storablesWithIdGt1 = " + storablesWithIdGt1);
        for (Storable storable : storablesWithIdGt1) {
            Assert.assertTrue(storable.getId() > 1L);
        }
        Collection<Storable> allStorables = getStorageManager().list(searchQuery.getNameSpace());
        System.out.println("list = " + allStorables);
        Assert.assertEquals(allStorables.size() - 1, storablesWithIdGt1.size());
    }
}
Also used : SearchQuery(com.hortonworks.registries.storage.search.SearchQuery) StorableTest(com.hortonworks.registries.storage.StorableTest) Storable(com.hortonworks.registries.storage.Storable) AbstractStoreManagerTest(com.hortonworks.registries.storage.AbstractStoreManagerTest) StorableTest(com.hortonworks.registries.storage.StorableTest) Test(org.junit.Test) IntegrationTest(com.hortonworks.registries.common.test.IntegrationTest)

Example 2 with StorableTest

use of com.hortonworks.registries.storage.StorableTest in project registry by hortonworks.

the class JdbcStorageManagerIntegrationTest method testAdd_UnequalExistingStorable_AlreadyExistsException.

// =============== TEST METHODS ===============
@Test(expected = Exception.class)
public void testAdd_UnequalExistingStorable_AlreadyExistsException() {
    for (StorableTest test : storableTests) {
        Storable storable1 = test.getStorableList().get(0);
        Storable storable2 = test.getStorableList().get(1);
        Assert.assertEquals(storable1.getStorableKey(), storable2.getStorableKey());
        Assert.assertNotEquals(storable1, storable2);
        getStorageManager().add(storable1);
        // should throw exception
        getStorageManager().add(storable2);
    }
}
Also used : StorableTest(com.hortonworks.registries.storage.StorableTest) Storable(com.hortonworks.registries.storage.Storable) AbstractStoreManagerTest(com.hortonworks.registries.storage.AbstractStoreManagerTest) StorableTest(com.hortonworks.registries.storage.StorableTest) Test(org.junit.Test) IntegrationTest(com.hortonworks.registries.common.test.IntegrationTest)

Example 3 with StorableTest

use of com.hortonworks.registries.storage.StorableTest in project registry by hortonworks.

the class JdbcStorageManagerIntegrationTest method testList_EmptyDb_EmptyCollection.

@Test
public void testList_EmptyDb_EmptyCollection() {
    for (StorableTest test : storableTests) {
        Collection<Storable> found = getStorageManager().list(test.getStorableList().get(0).getStorableKey().getNameSpace());
        Assert.assertNotNull(found);
        Assert.assertTrue(found.isEmpty());
    }
}
Also used : StorableTest(com.hortonworks.registries.storage.StorableTest) Storable(com.hortonworks.registries.storage.Storable) AbstractStoreManagerTest(com.hortonworks.registries.storage.AbstractStoreManagerTest) StorableTest(com.hortonworks.registries.storage.StorableTest) Test(org.junit.Test) IntegrationTest(com.hortonworks.registries.common.test.IntegrationTest)

Aggregations

IntegrationTest (com.hortonworks.registries.common.test.IntegrationTest)3 AbstractStoreManagerTest (com.hortonworks.registries.storage.AbstractStoreManagerTest)3 Storable (com.hortonworks.registries.storage.Storable)3 StorableTest (com.hortonworks.registries.storage.StorableTest)3 Test (org.junit.Test)3 SearchQuery (com.hortonworks.registries.storage.search.SearchQuery)1