Skip to content

Instantly share code, notes, and snippets.

@sonOfRa
Created February 19, 2019 13:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sonOfRa/b9ad08a521ef50e66f63e8b0f7aef348 to your computer and use it in GitHub Desktop.
Save sonOfRa/b9ad08a521ef50e66f63e8b0f7aef348 to your computer and use it in GitHub Desktop.
@RunWith(SpringRunner.class)
@SpringBootTest
@ActiveProfiles("test")
public class FeedbackServiceTests {
@Rule
public ExpectedException thrown = ExpectedException.none();
@Test
public void testCreateInvalidTopicAndScale() {
CreateFeedback fb1 = new CreateFeedback();
fb1.setEntryDate(TODAY);
fb1.setFeedbackDate(TODAY);
fb1.setFeedbackLocationId(1L);
fb1.setLocationId(1L);
fb1.setNote("A note");
List<CreateFeedbackItem> items = new ArrayList<>();
items.add(acceptedItemDtos.get(0));
items.add(badScaleAndTopic);
fb1.setFeedbackItems(items);
for (CreateFeedbackItem item : items) {
item.setFeedback(fb1);
}
thrown.expect(NonAcceptedFeedbackException.class);
feedbackService.create(fb1);
Assert.assertEquals("There should be zero feedbacks in the database",
0, JdbcTestUtils.countRowsInTable(jdbcTemplate, "feedback"));
Assert.assertEquals("There should be zero feedback items in the database",
0, JdbcTestUtils.countRowsInTable(jdbcTemplate, "feedback_item"));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment