Search in sources :

Example 66 with Status

use of com.marcnuri.yakc.model.io.k8s.apimachinery.pkg.apis.meta.v1.Status in project mimock by neel1996.

the class MockManagementControllerTest method shouldReturnHttpBadRequest_FilteredListMocksApi_WithoutStatusQueryParam.

@Test
void shouldReturnHttpBadRequest_FilteredListMocksApi_WithoutStatusQueryParam() throws Exception {
    // Arrange
    String route = UrlConfig.MOCKS_PATH + "/" + UrlConfig.MOCKS_FILTER;
    Page<Mock> expectedMocks = new PageImpl<>(new ArrayList<>());
    lenient().when(mockManagementService.getAllActiveMocks(any(Pageable.class), any(Status.class))).thenReturn(expectedMocks);
    // Act
    MvcResult result = mockMvc.perform(get(route)).andExpect(status().isBadRequest()).andReturn();
    // Assert
    assertEquals("", result.getResponse().getContentAsString());
}
Also used : PageImpl(org.springframework.data.domain.PageImpl) Status(com.arbindo.mimock.manage.mimocks.models.v1.Status) HttpStatus(org.springframework.http.HttpStatus) Pageable(org.springframework.data.domain.Pageable) JsonMapper.convertObjectToJsonString(com.arbindo.mimock.helpers.general.JsonMapper.convertObjectToJsonString) RandomDataGenerator.generateRandomAlphabeticString(com.arbindo.mimock.helpers.general.RandomDataGenerator.generateRandomAlphabeticString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) MvcResult(org.springframework.test.web.servlet.MvcResult) Mock(com.arbindo.mimock.entities.Mock) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) WebMvcTest(org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)

Example 67 with Status

use of com.marcnuri.yakc.model.io.k8s.apimachinery.pkg.apis.meta.v1.Status in project bmoth by hhu-stups.

the class Z3ConnectionTest method testSimpleCallToZ3.

@Test
public void testSimpleCallToZ3() {
    // a = b & a = 5
    Expr a = z3Context.mkIntConst("a");
    Expr b = z3Context.mkIntConst("b");
    BoolExpr constraint = z3Context.mkAnd(z3Context.mkEq(a, b), z3Context.mkEq(a, z3Context.mkInt(5)));
    z3Solver.add(constraint);
    Status check = z3Solver.check();
    assertEquals(Status.SATISFIABLE, check);
    assertEquals(z3Context.mkInt(5), z3Solver.getModel().eval(a, true));
    assertEquals(z3Context.mkInt(5), z3Solver.getModel().eval(b, true));
}
Also used : Status(com.microsoft.z3.Status) BoolExpr(com.microsoft.z3.BoolExpr) BoolExpr(com.microsoft.z3.BoolExpr) Expr(com.microsoft.z3.Expr) Test(org.junit.Test)

Example 68 with Status

use of com.marcnuri.yakc.model.io.k8s.apimachinery.pkg.apis.meta.v1.Status in project bmoth by hhu-stups.

the class Z3ConnectionTest method testQuantifiedFormula.

@Test
public void testQuantifiedFormula() {
    Expr a = z3Context.mkIntConst("a");
    Expr b = z3Context.mkIntConst("b");
    BoolExpr constraint = z3Context.mkAnd(z3Context.mkEq(a, b), z3Context.mkEq(a, z3Context.mkInt(5)), z3Context.mkEq(b, z3Context.mkInt(7)));
    constraint = z3Context.mkExists(new Expr[] { a, b }, constraint, 1, null, null, null, null);
    z3Solver.add(constraint);
    Status check = z3Solver.check();
    assertEquals(Status.UNSATISFIABLE, check);
}
Also used : Status(com.microsoft.z3.Status) BoolExpr(com.microsoft.z3.BoolExpr) BoolExpr(com.microsoft.z3.BoolExpr) Expr(com.microsoft.z3.Expr) Test(org.junit.Test)

Example 69 with Status

use of com.marcnuri.yakc.model.io.k8s.apimachinery.pkg.apis.meta.v1.Status in project bmoth by hhu-stups.

the class BooleanFormulaEvaluationTest method testSimpleBooleanFormula.

@Test
public void testSimpleBooleanFormula() throws Exception {
    String formula = "x = TRUE & y = FALSE";
    // getting the translated z3 representation of the formula
    BoolExpr constraint = FormulaToZ3Translator.translatePredicate(formula, z3Context);
    z3Solver.add(constraint);
    Status check = z3Solver.check();
    Expr x = z3Context.mkBoolConst("x");
    Expr y = z3Context.mkBoolConst("y");
    assertEquals(Status.SATISFIABLE, check);
    assertEquals(z3Context.mkBool(true), z3Solver.getModel().eval(x, true));
    assertEquals(z3Context.mkBool(false), z3Solver.getModel().eval(y, false));
}
Also used : Status(com.microsoft.z3.Status) BoolExpr(com.microsoft.z3.BoolExpr) BoolExpr(com.microsoft.z3.BoolExpr) Expr(com.microsoft.z3.Expr) Test(org.junit.Test)

Example 70 with Status

use of com.marcnuri.yakc.model.io.k8s.apimachinery.pkg.apis.meta.v1.Status in project bmoth by hhu-stups.

the class SetFormulaEvaluationTest method testnoSubset.

@Test
public void testnoSubset() {
    String formula = "{1} /<: {1}";
    BoolExpr constraint = FormulaToZ3Translator.translatePredicate(formula, z3Context);
    z3Solver.add(constraint);
    Status check = z3Solver.check();
    assertEquals(Status.UNSATISFIABLE, check);
}
Also used : Status(com.microsoft.z3.Status) BoolExpr(com.microsoft.z3.BoolExpr) Test(org.junit.Test)

Aggregations

Status (com.microsoft.z3.Status)63 BoolExpr (com.microsoft.z3.BoolExpr)55 Test (org.junit.Test)49 Test (org.junit.jupiter.api.Test)17 Expr (com.microsoft.z3.Expr)10 IOException (java.io.IOException)10 JsonMapper.convertObjectToJsonString (com.arbindo.mimock.helpers.general.JsonMapper.convertObjectToJsonString)9 RandomDataGenerator.generateRandomAlphabeticString (com.arbindo.mimock.helpers.general.RandomDataGenerator.generateRandomAlphabeticString)9 Status (com.arbindo.mimock.manage.mimocks.models.v1.Status)9 Context (com.microsoft.z3.Context)9 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)9 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)9 WebMvcTest (org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)9 Pageable (org.springframework.data.domain.Pageable)9 HttpStatus (org.springframework.http.HttpStatus)9 MvcResult (org.springframework.test.web.servlet.MvcResult)9 Mock (com.arbindo.mimock.entities.Mock)8 List (java.util.List)7 Solver (com.microsoft.z3.Solver)6 PageImpl (org.springframework.data.domain.PageImpl)6