use of fi.thl.covid19.exposurenotification.diagnosiskey.v1.Status in project mimock by neel1996.
the class MockManagementControllerTest method shouldReturnHttpBadRequest_CreateMockApi_WithInvalidParametersForHttpMethodInRequest_ReturnsValidationErrors.
@ParameterizedTest
@NullSource
@EmptySource
void shouldReturnHttpBadRequest_CreateMockApi_WithInvalidParametersForHttpMethodInRequest_ReturnsValidationErrors(String testData) throws Exception {
// Arrange
MockMultipartFile file = getMockMultipartFile();
MockRequest mockRequest = createMockRequestWithFile(file);
// Modify the MockRequest.HttpMethod to check
mockRequest.setHttpMethod(testData);
String route = UrlConfig.MOCKS_PATH;
// Act and Assert
mockMvc.perform(multipart(route).file(file).param("name", mockRequest.getName()).param("route", mockRequest.getRoute()).param("httpMethod", mockRequest.getHttpMethod()).param("responseContentType", mockRequest.getResponseContentType()).param("statusCode", String.valueOf(mockRequest.getStatusCode())).param("expectedTextResponse", mockRequest.getExpectedTextResponse()).param("description", mockRequest.getDescription())).andExpect(status().isBadRequest()).andExpect(response -> assertNotNull(response.getResolvedException())).andExpect(response -> assertTrue(response.getResolvedException().getMessage().contains("HttpMethod is required"))).andReturn();
}
use of fi.thl.covid19.exposurenotification.diagnosiskey.v1.Status in project mimock by neel1996.
the class MockManagementControllerTest method shouldReturnHttpOk_FilteredListMocksApi_ReturnsNull.
@Test
void shouldReturnHttpOk_FilteredListMocksApi_ReturnsNull() throws Exception {
// Arrange
String route = UrlConfig.MOCKS_PATH + "/" + UrlConfig.MOCKS_FILTER;
lenient().when(mockManagementService.getAllActiveMocks(any(Pageable.class), any(Status.class))).thenReturn(null);
// Act
MvcResult result = mockMvc.perform(get(route).param("status", "NONE")).andExpect(status().isOk()).andReturn();
// Assert
assertEquals("", result.getResponse().getContentAsString());
}
use of fi.thl.covid19.exposurenotification.diagnosiskey.v1.Status in project mimock by neel1996.
the class MockManagementControllerTest method shouldReturnHttpOk_FilteredListMocksApi_ReturnsListOfMocks.
@Test
void shouldReturnHttpOk_FilteredListMocksApi_ReturnsListOfMocks() throws Exception {
// Arrange
String route = UrlConfig.MOCKS_PATH + "/" + UrlConfig.MOCKS_FILTER;
String expectedContentType = "application/json";
Page<Mock> expectedMocks = generateMocksPageable();
String expectedResponseBody = convertObjectToJsonString(expectedMocks);
lenient().when(mockManagementService.getAllActiveMocks(any(Pageable.class), any(Status.class))).thenReturn(expectedMocks);
// Act
MvcResult result = mockMvc.perform(get(route).param("status", "NONE")).andExpect(status().isOk()).andExpect(content().contentType(expectedContentType)).andReturn();
// Assert
assertEquals(expectedResponseBody, result.getResponse().getContentAsString());
}
use of fi.thl.covid19.exposurenotification.diagnosiskey.v1.Status in project bmoth by hhu-stups.
the class InitialStateExistsChecker method doInitialStateExistsCheck.
static InitialStateExistsCheckingResult doInitialStateExistsCheck(MachineNode machine) {
Context ctx = new Context();
Solver solver = Z3SolverFactory.getZ3Solver(ctx);
MachineToZ3Translator machineTranslator = new MachineToZ3Translator(machine, ctx);
final BoolExpr invariant = machineTranslator.getInitialValueConstraint();
solver.add(invariant);
Status check = solver.check();
return new InitialStateExistsCheckingResult(check);
}
use of fi.thl.covid19.exposurenotification.diagnosiskey.v1.Status in project bmoth by hhu-stups.
the class InvariantSatisfiabilityChecker method doInvariantSatisfiabilityCheck.
static InvariantSatisfiabilityCheckingResult doInvariantSatisfiabilityCheck(MachineNode machine) {
Context ctx = new Context();
Solver solver = Z3SolverFactory.getZ3Solver(ctx);
MachineToZ3Translator machineTranslator = new MachineToZ3Translator(machine, ctx);
final BoolExpr invariant = machineTranslator.getInvariantConstraint();
solver.add(invariant);
Status check = solver.check();
return new InvariantSatisfiabilityCheckingResult(check);
}
Aggregations