Search in sources :

Example 1 with TestContentRepositoryDAO

use of org.sonatype.nexus.repository.content.store.example.TestContentRepositoryDAO in project nexus-public by sonatype.

the class SearchIndexUpgradeTest method testMigration.

@Test
public void testMigration() throws Exception {
    try (Connection conn = store.openConnection()) {
        underTest.migrate(conn);
    }
    try (DataSession<?> session = sessionRule.openSession(DEFAULT_DATASTORE_NAME)) {
        TestContentRepositoryDAO dao = session.access(TestContentRepositoryDAO.class);
        Optional<ContentRepository> foundHosted = dao.readContentRepository(hosted1Config.getId());
        Optional<ContentRepository> foundProxy = dao.readContentRepository(proxyConfig.getId());
        Optional<ContentRepository> foundGroup = dao.readContentRepository(groupConfig.getId());
        assertTrue(isRepositoryMarked(foundHosted.get()));
        assertTrue(isRepositoryMarked(foundProxy.get()));
        assertFalse(isRepositoryMarked(foundGroup.get()));
        // test that existing attributes are still there
        Map<String, Object> fooAttrs = (Map<String, Object>) foundProxy.get().attributes().get("test");
        assertEquals("3", fooAttrs.get("value"));
    }
}
Also used : TestContentRepositoryDAO(org.sonatype.nexus.repository.content.store.example.TestContentRepositoryDAO) Connection(java.sql.Connection) ContentRepository(org.sonatype.nexus.repository.content.ContentRepository) Map(java.util.Map) NestedAttributesMap(org.sonatype.nexus.common.collect.NestedAttributesMap) ImmutableMap(com.google.common.collect.ImmutableMap) Test(org.junit.Test)

Aggregations

ImmutableMap (com.google.common.collect.ImmutableMap)1 Connection (java.sql.Connection)1 Map (java.util.Map)1 Test (org.junit.Test)1 NestedAttributesMap (org.sonatype.nexus.common.collect.NestedAttributesMap)1 ContentRepository (org.sonatype.nexus.repository.content.ContentRepository)1 TestContentRepositoryDAO (org.sonatype.nexus.repository.content.store.example.TestContentRepositoryDAO)1