Skip to content

Commit

Permalink
Adds tests for TopicManagementService
Browse files Browse the repository at this point in the history
  • Loading branch information
zindlsn committed Mar 23, 2020
1 parent 5b34891 commit ca2a6b4
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package de.stefanzindl.calendernews;

import de.stefanzindl.calendernews.boundary.ActionDayManagementService;
import de.stefanzindl.calendernews.boundary.TopicManagementService;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
Expand All @@ -23,4 +24,14 @@ public class MockedManagementServiceConfiguration {
public ActionDayManagementService actionDayManagementService() {
return mock(ActionDayManagementService.class);
}

/**
* Creates the mocked {@link de.stefanzindl.calendernews.boundary.TopicManagementService}.
*
* @return the mocked TopicManagementService
*/
@Bean
public TopicManagementService topicManagementService() {
return mock(TopicManagementService.class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package de.stefanzindl.calendernews.boundary;

import de.stefanzindl.calendernews.dto.v1.TopicDto;
import de.stefanzindl.calendernews.util.dto.TopicDtoBuilder;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.UUID;

/**
* Test class for {@link ActionDayManagementService}.
*/
@RunWith(SpringRunner.class)
@SpringBootTest
public class TopicManagementServiceTest {

@Autowired
private TopicManagementService topicManagementService;

private TopicDto topicDto;

/**
* Initializes the test.
*/
@Before
public void init() {
this.topicDto = TopicDtoBuilder.instance().build();
}

/**
* Saves and loads a topic-dto.
*/
@Test
public void createActionDayDtoWithoutTopicSuccessfully() {
UUID identifier = this.topicManagementService.saveTopic(topicDto);
TopicDto loadedTopic = topicManagementService.findTopicByTopicIdentifier(identifier);

Assert.assertEquals(topicDto.getTopicIdentifier(), loadedTopic.getTopicIdentifier());
Assert.assertEquals(topicDto.getName(), loadedTopic.getName());
Assert.assertNotNull(loadedTopic);
}
}

0 comments on commit ca2a6b4

Please sign in to comment.