@Override public TopicListCacheEntry compute(EndpointObjectHash key) { LOG.debug("Fetching result for getTopicListByHash {}", key); TopicListEntryDto entryDto = endpointService.findTopicListEntryByHash(key.getData()); if (entryDto != null) { return new TopicListCacheEntry( entryDto.getSimpleHash(), EndpointObjectHash.fromBytes(entryDto.getHash()), entryDto.getTopics()); } else { return null; } } });
@Test public void findTopicListEntryByHashTest() { ApplicationDto applicationDto = generateApplicationDto(); TopicDto topicDto = generateTopicDto(applicationDto.getId(), TopicTypeDto.MANDATORY); List<TopicDto> topics = Arrays.asList(topicDto); byte[] hash = "123".getBytes(); TopicListEntryDto topicListEntryDto = new TopicListEntryDto(1, hash, topics); endpointService.saveTopicListEntry(topicListEntryDto); TopicListEntryDto foundTopicListEntry = endpointService.findTopicListEntryByHash(hash); Assert.assertEquals(topicListEntryDto, foundTopicListEntry); }