Skip to content

Commit

Permalink
rework tests to minimize warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
laffer1 committed Jan 4, 2024
1 parent e92957b commit 4004724
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,19 @@ public void setup() {
license.setName("NAME");
license.setId(1);
license.setCreated(Calendar.getInstance().getTime());

when(service.list()).thenReturn(Collections.singletonList(license));
when(service.get(1)).thenReturn(license);
when(service.getByName("NAME")).thenReturn(license);
}

@Test
void testList() {
when(service.list()).thenReturn(Collections.singletonList(license));
final ResponseEntity<List<License>> result = controller.list();
assertNotNull(result);
assertEquals(1, Objects.requireNonNull(result.getBody()).size());
}

@Test
void testGet() {
when(service.get(1)).thenReturn(license);
final ResponseEntity<License> result = controller.get(1);
assertNotNull(result);
assertEquals("NAME", result.getBody().getName());
Expand All @@ -63,6 +61,7 @@ void testGet() {

@Test
void testGetByName() {
when(service.getByName("NAME")).thenReturn(license);
final ResponseEntity<License> result = controller.get("NAME");
assertNotNull(result);
assertEquals("NAME", result.getBody().getName());
Expand Down

0 comments on commit 4004724

Please sign in to comment.