@@ -0,0 +1,2321 @@
+package rs.radinovic.spring_boot_demo;%0A%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.springframework.test.web.servlet.MockMvc;%0Aimport rs.radinovic.spring_boot_demo.domain.Item;%0Aimport rs.radinovic.spring_boot_demo.service.ItemService;%0Aimport rs.radinovic.spring_boot_demo.web.ItemController;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0Aimport static org.hamcrest.Matchers.hasSize;%0Aimport static org.hamcrest.Matchers.is;%0Aimport static org.mockito.Mockito.mock;%0Aimport static org.mockito.Mockito.when;%0Aimport static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;%0Aimport static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;%0Aimport static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;%0Aimport static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;%0Aimport static org.springframework.test.web.servlet.setup.MockMvcBuilders.standaloneSetup;%0A%0Apublic class ItemControllerTest %7B%0A%0A    private ItemService itemService;%0A    private MockMvc mockMvc;%0A%0A    @Before%0A    public void setup() %7B%0A        itemService = mock(ItemService.class);%0A        this.mockMvc = standaloneSetup(new ItemController(itemService)).build();%0A    %7D%0A%0A    @Test%0A    public void testFindAllItems() throws Exception %7B%0A        List%3CItem%3E items = createDummyItemsList(4);%0A        when(itemService.findAllItems()).thenReturn(items);%0A        this.mockMvc.perform(get(%22/api/items%22))%0A                .andExpect(status().isOk())%0A                .andExpect(content().contentType(%22application/json;charset=UTF-8%22))%0A                .andExpect(jsonPath(%22$%22, hasSize(items.size())))%0A                .andExpect(jsonPath(%22$%5B0%5D.id%22, is(Math.toIntExact(items.get(0).getId()))))%0A                .andExpect(jsonPath(%22$%5B0%5D.name%22, is(items.get(0).getName())))%0A                .andExpect(jsonPath(%22$%5B0%5D.description%22, is(items.get(0).getDescription())));%0A%0A    %7D%0A%0A    private List%3CItem%3E createDummyItemsList(int listSize) %7B%0A        List%3CItem%3E items = new ArrayList%3C%3E();%0A        for (int i = 0; i %3C listSize; i++) %7B%0A            Item item = new Item();%0A            item.setId(i + 1L);%0A            item.setName(%22item name %22 + i);%0A            item.setDescription(%22item description %22 + i);%0A            items.add(item);%0A        %7D%0A        return items;%0A    %7D%0A%7D%0A

Add ItemControllerTest with unit test for getting all items