Search in sources :

Example 1 with ContentPackList

use of org.graylog2.rest.models.system.contentpacks.responses.ContentPackList in project graylog2-server by Graylog2.

the class ContentPackResourceTest method listAndLatest.

@Test
public void listAndLatest() throws Exception {
    final ContentPack contentPack = objectMapper.readValue(CONTENT_PACK, ContentPack.class);
    final Set<ContentPack> contentPacks = Collections.singleton(contentPack);
    final Map<ModelId, Map<Integer, ContentPackMetadata>> metaDataMap = Collections.emptyMap();
    final ContentPackList expectedList = ContentPackList.create(contentPacks.size(), contentPacks, metaDataMap);
    when(contentPackPersistenceService.loadAll()).thenReturn(Collections.singleton(contentPack));
    final ContentPackList contentPackList = contentPackResource.listContentPacks();
    verify(contentPackPersistenceService, times(1)).loadAll();
    assertThat(contentPackList).isEqualTo(expectedList);
    when(contentPackPersistenceService.loadAllLatest()).thenReturn(Collections.singleton(contentPack));
    final ContentPackList contentPackLatest = contentPackResource.listLatestContentPacks();
    verify(contentPackPersistenceService, times(1)).loadAll();
    assertThat(contentPackLatest).isEqualTo(expectedList);
}
Also used : ContentPackList(org.graylog2.rest.models.system.contentpacks.responses.ContentPackList) ContentPack(org.graylog2.contentpacks.model.ContentPack) Map(java.util.Map) ModelId(org.graylog2.contentpacks.model.ModelId) Test(org.junit.Test)

Aggregations

Map (java.util.Map)1 ContentPack (org.graylog2.contentpacks.model.ContentPack)1 ModelId (org.graylog2.contentpacks.model.ModelId)1 ContentPackList (org.graylog2.rest.models.system.contentpacks.responses.ContentPackList)1 Test (org.junit.Test)1