Search in sources :

Example 16 with Status

use of com.arbindo.mimock.manage.mimocks.models.v1.Status in project bmoth by hhu-stups.

the class BooleanFormulaEvaluationTest method testTrueFormula.

@Test
public void testTrueFormula() throws Exception {
    String formula = "x = TRUE";
    // 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");
    assertEquals(SATISFIABLE, check);
    assertEquals(z3Context.mkTrue(), z3Solver.getModel().eval(x, 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 17 with Status

use of com.arbindo.mimock.manage.mimocks.models.v1.Status in project bmoth by hhu-stups.

the class BooleanFormulaEvaluationTest method testFalseFormula.

@Test
public void testFalseFormula() throws Exception {
    String formula = "x = 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");
    assertEquals(SATISFIABLE, check);
    assertEquals(z3Context.mkFalse(), z3Solver.getModel().eval(x, 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 18 with Status

use of com.arbindo.mimock.manage.mimocks.models.v1.Status in project bmoth by hhu-stups.

the class BooleanFormulaEvaluationTest method testImplication.

@Test
public void testImplication() throws Exception {
    String formula = "1=1 => x";
    // 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");
    assertEquals(SATISFIABLE, check);
    assertEquals(z3Context.mkBool(true), z3Solver.getModel().eval(x, 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 19 with Status

use of com.arbindo.mimock.manage.mimocks.models.v1.Status in project bmoth by hhu-stups.

the class SetFormulaEvaluationTest method testDifference2.

@Test
public void testDifference2() {
    String formula = "{1,2}\\{3} = {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)

Example 20 with Status

use of com.arbindo.mimock.manage.mimocks.models.v1.Status in project bmoth by hhu-stups.

the class SetFormulaEvaluationTest method testnoSubset2.

@Test
public void testnoSubset2() {
    String formula = "{1} /<: {2,3}";
    BoolExpr constraint = FormulaToZ3Translator.translatePredicate(formula, z3Context);
    z3Solver.add(constraint);
    Status check = z3Solver.check();
    assertEquals(Status.SATISFIABLE, 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)21 JsonMapper.convertObjectToJsonString (com.arbindo.mimock.helpers.general.JsonMapper.convertObjectToJsonString)13 RandomDataGenerator.generateRandomAlphabeticString (com.arbindo.mimock.helpers.general.RandomDataGenerator.generateRandomAlphabeticString)13 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)13 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)13 WebMvcTest (org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)13 MvcResult (org.springframework.test.web.servlet.MvcResult)13 Mock (com.arbindo.mimock.entities.Mock)12 Expr (com.microsoft.z3.Expr)10 IOException (java.io.IOException)10 MockRequest (com.arbindo.mimock.manage.mimocks.models.v1.MockRequest)9 ProcessedMockRequest (com.arbindo.mimock.manage.mimocks.models.v1.ProcessedMockRequest)9 Status (com.arbindo.mimock.manage.mimocks.models.v1.Status)9 Context (com.microsoft.z3.Context)9 Pageable (org.springframework.data.domain.Pageable)9 HttpStatus (org.springframework.http.HttpStatus)9 MockMultipartFile (org.springframework.mock.web.MockMultipartFile)9