Skip to content

Commit

Permalink
updated code
Browse files Browse the repository at this point in the history
  • Loading branch information
oleksiybozhykntt committed Jan 13, 2025
1 parent e86f939 commit e39f2d5
Showing 1 changed file with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@
import java.util.ArrayList;
import java.util.List;
import org.junit.jupiter.api.Test;
import org.mockito.InjectMocks;
import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Order;
import org.springframework.http.MediaType;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.test.web.servlet.MockMvc;
Expand All @@ -27,32 +25,32 @@
})
@AutoConfigureMockMvc(addFilters = false)
class TaxonomyControllerTest {

@Autowired
private MockMvc mockMvc;

@MockitoBean
private TaxonomyService taxonomyServiceMock;
@InjectMocks
private TaxonomyController taxonomyController;

@Test
void getDistinctOrgType () throws Exception {
List<DistinctOrganizationTypeDTO> orgTypes = new ArrayList<DistinctOrganizationTypeDTO>();
orgTypes.add(0, new DistinctOrganizationTypeDTO() {
void getDistinctOrgType() throws Exception {
List<DistinctOrganizationTypeDTO> orgTypes = new ArrayList<>();
orgTypes.add(new DistinctOrganizationTypeDTO() {
@Override
public String getOrganizationType () {
public String getOrganizationType() {
return "test";
}

@Override
public String getOrganizationTypeDescription () {
public String getOrganizationTypeDescription() {
return "test";
}
});

Mockito.when(taxonomyServiceMock.getDistinctOrganizationType(Sort.by(Order.asc("organizationType")))).thenReturn(orgTypes);
Mockito.when(taxonomyServiceMock.getDistinctOrganizationType(Sort.by(Sort.Order.asc("organizationType")))).thenReturn(orgTypes);

mockMvc.perform(get("/taxonomy/custom/getDistinctOrganizationType")
.param("sort","organizationType,ASC")
.param("sort", "organizationType,ASC")
.accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
Expand Down

0 comments on commit e39f2d5

Please sign in to comment.