Skip to content

Commit

Permalink
testing
Browse files Browse the repository at this point in the history
  • Loading branch information
ramueSVA committed Nov 14, 2024
1 parent 420b52d commit 3607569
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,21 @@
""")
public class ManagerControllerFeatureDisabledIT extends IntegrationTest {

private static final String MANAGER_PATH = "/manager";

@Autowired
public MockMvc mockMvc;

private static final String PATH = "/manager/execute/query";
@Autowired
private ObjectMapper mapper;

@Test
@SneakyThrows
@WithMockNumUser(roles = {"MANAGER"})
public void execute() {
public void executeQuery() {
QueryDto queryDto = new QueryDto();

mockMvc.perform(post(PATH).with(csrf())
mockMvc.perform(post(MANAGER_PATH + "/execute/query").with(csrf())
.contentType(MediaType.APPLICATION_JSON)
.content(mapper.writeValueAsString(queryDto))
).andExpect(status().isNotFound());
Expand All @@ -41,10 +42,10 @@ public void execute() {
@Test
@SneakyThrows
@WithMockNumUser()
public void executeAsNonAuthorizedUser() {
public void executeQueryAsNonAuthorizedUser() {
QueryDto queryDto = new QueryDto();

mockMvc.perform(post(PATH).with(csrf())
mockMvc.perform(post(MANAGER_PATH + "/execute/query").with(csrf())
.contentType(MediaType.APPLICATION_JSON)
.content(mapper.writeValueAsString(queryDto))
).andExpect(status().isNotFound());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void executeQuery() {
var expectedResult = mapper.writeValueAsString(queryResponseData);

ehrClient
.when(HttpRequest.request().withMethod("POST").withHeaders(AUTH_HEADER).withPath("/ehrbase/rest/openehr/v1/query/aql/").withBody(StringBody.subString(query, StandardCharsets.UTF_8)))
.when(HttpRequest.request().withMethod("POST").withPath("/ehrbase/rest/openehr/v1/query/aql/").withBody(StringBody.subString(query, StandardCharsets.UTF_8)))
.respond(HttpResponse.response().withStatusCode(HttpStatusCode.OK_200.code()).withBody(expectedResult, org.mockserver.model.MediaType.JSON_UTF_8));

MvcResult result =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@
import org.highmed.numportal.domain.repository.OrganizationRepository;
import org.highmed.numportal.domain.repository.ProjectRepository;
import org.highmed.numportal.domain.repository.UserDetailsRepository;
import org.highmed.numportal.service.ProjectService;
import org.highmed.numportal.service.util.ExportHeaderUtil;
import org.highmed.numportal.service.util.ExportUtil;

import java.time.LocalDate;
import java.util.List;
Expand All @@ -56,8 +53,7 @@ public class ProjectControllerIT extends IntegrationTest {
.registerModule(new PageJacksonModule())
.registerModule(new SortJacksonModule())
.registerModule(new JavaTimeModule());
@Autowired private ExportUtil exportUtil;
@Autowired private ExportHeaderUtil exportHeaderUtil;

@Autowired private ProjectRepository projectRepository;
@Autowired private UserDetailsRepository userDetailsRepository;
@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import org.highmed.numportal.service.util.ExportHeaderUtil;
import org.highmed.numportal.service.util.ExportUtil;

import org.ehrbase.openehr.sdk.response.dto.QueryResponseData;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Ignore;
Expand All @@ -51,13 +50,9 @@
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.util.MultiValueMap;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody;

import java.io.IOException;
import java.time.LocalDateTime;
import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand Down

0 comments on commit 3607569

Please sign in to comment.