@Override public TopicListEntryDto saveTopicListEntry(TopicListEntryDto topicListEntryDto) { LOG.debug("Saving topic list entry: [{}]", topicListEntryDto); return getDto(topicListEntryDao.save(topicListEntryDto)); }
@Test public void findEndpointUserConfigurationDtoTest() throws IOException { List<TopicDto> topics = new ArrayList<>(); topics.add(generateTopicDto(null, TopicTypeDto.OPTIONAL)); byte[] hash = "hash".getBytes(); int simpleHash = 123; TopicListEntryDto topicListEntryDto = new TopicListEntryDto(123, hash, topics); topicListEntryDao.save(topicListEntryDto); MongoTopicListEntry topicListEntry = topicListEntryDao.findByHash(hash); Assert.assertEquals(simpleHash, topicListEntry.getSimpleHash()); } }
@Override @Transactional public TopicListEntryDto findTopicListEntryByHash(byte[] hash) { LOG.debug("Looking for a topic list entry by hash: [{}]", hash); TopicListEntry topicListEntry = topicListEntryDao.findByHash(hash); List<TopicDto> foundTopics = ModelUtils.convertDtoList(topicDao.findTopicsByIds( topicListEntry.getTopicIds())); TopicListEntryDto topicListEntryDto = getDto(topicListEntry); topicListEntryDto.setTopics(foundTopics); return topicListEntryDto; }
@Test public void testFindByHash() throws Exception { List<TopicDto> topics = new ArrayList<>(); TopicDto topicDto = new TopicDto(); topicDto.setId("6123"); topics.add(topicDto); byte[] hash = "hash".getBytes(); int simpleHash = 123; TopicListEntryDto topicListEntryDto = new TopicListEntryDto(123, hash, topics); topicListEntryDao.save(topicListEntryDto); CassandraTopicListEntry topicListEntry = topicListEntryDao.findByHash(hash); Assert.assertEquals(simpleHash, topicListEntry.getSimpleHash()); } }