Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgePatrascan committed Oct 3, 2018
1 parent 464ad04 commit 5fd6681
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.*;

import static org.hamcrest.Matchers.*;
import static org.mockito.ArgumentMatchers.anyLong;
Expand Down Expand Up @@ -79,6 +77,19 @@ void processFindFormReturnOne() throws Exception {
.andExpect(view().name("redirect:/owners/1"));
}

@Test
void processFindFormEmptyReturnMany() throws Exception {
when(ownerService.findAllByLastNameLike(anyString()))
.thenReturn(Arrays.asList(Owner.builder().id(1l).build(),
Owner.builder().id(2l).build()));

mockMvc.perform(get("/owners")
.param("lastName",""))
.andExpect(status().isOk())
.andExpect(view().name("owners/ownersList"))
.andExpect(model().attribute("selections", hasSize(2)));;
}

@Test
void displayOwner() throws Exception {
when(ownerService.findById(anyLong())).thenReturn(Owner.builder().id(1l).build());
Expand Down

0 comments on commit 5fd6681

Please sign in to comment.