Search in sources :

Example 1 with IdentifierKeyValuePair

use of org.nzbhydra.searching.IdentifierKeyValuePair in project nzbhydra2 by theotherp.

the class SqliteMigrationTest method shouldMigrateSearches.

// TODO tests are still for old json based sqlite migration, need to be adapted to actual sqlite access
@Test
@Ignore
public void shouldMigrateSearches() throws Exception {
    String searchesJson = Resources.toString(Resources.getResource(SqliteMigrationTest.class, "searches"), Charsets.UTF_8);
    List<Map<String, Object>> oldSearches = testee.objectMapper.readValue(searchesJson, testee.listOfMapsTypeReference);
    Map<Integer, SearchEntity> searchEntities = testee.migrateSearches();
    assertThat(searchEntities.size(), is(4));
    SearchEntity entityTv = searchEntities.get(3);
    assertThat(entityTv.getAuthor(), is(nullValue()));
    assertThat(entityTv.getUsername(), is(nullValue()));
    assertThat(entityTv.getSeason(), is(1));
    assertThat(entityTv.getEpisode(), is(2));
    assertThat(entityTv.getIdentifiers().size(), is(1));
    IdentifierKeyValuePair keyValuePair = entityTv.getIdentifiers().iterator().next();
    assertThat(keyValuePair.getIdentifierKey(), is(IdType.TVDB.name()));
    assertThat(keyValuePair.getIdentifierValue(), is("456"));
    assertThat(entityTv.getQuery(), is(nullValue()));
    assertThat(entityTv.getSearchType(), is(SearchType.TVSEARCH));
    assertThat(entityTv.getCategoryName(), is("TV"));
    SearchEntity entityAll = searchEntities.get(2);
    assertThat(entityAll.getAuthor(), is(nullValue()));
    assertThat(entityAll.getUsername(), is(nullValue()));
    assertThat(entityAll.getEpisode(), is(nullValue()));
    assertThat(entityAll.getSeason(), is(nullValue()));
    assertThat(entityAll.getIdentifiers(), is(empty()));
    assertThat(entityAll.getQuery(), is("aquery"));
    assertThat(entityAll.getSearchType(), is(SearchType.SEARCH));
    assertThat(entityAll.getCategoryName(), is("All"));
}
Also used : IdentifierKeyValuePair(org.nzbhydra.searching.IdentifierKeyValuePair) SearchEntity(org.nzbhydra.searching.SearchEntity) HashMap(java.util.HashMap) Map(java.util.Map) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

HashMap (java.util.HashMap)1 Map (java.util.Map)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1 IdentifierKeyValuePair (org.nzbhydra.searching.IdentifierKeyValuePair)1 SearchEntity (org.nzbhydra.searching.SearchEntity)1