Search in sources :

Example 76 with PrismContext

use of com.evolveum.midpoint.prism.PrismContext in project midpoint by Evolveum.

the class TestFilterSimplifier method test020None.

@Test
public void test020None() throws Exception {
    System.out.println("===[ test020None ]===");
    // GIVEN
    PrismContext prismContext = PrismTestUtil.getPrismContext();
    // WHEN
    ObjectFilter filter = QueryBuilder.queryFor(UserType.class, prismContext).none().buildFilter();
    System.out.println("Original filter:\n" + filter.debugDump());
    // THEN
    ObjectFilter simplified = ObjectQueryUtil.simplify(filter);
    System.out.println("Simplified filter:\n" + DebugUtil.debugDump(simplified));
    assertTrue("Wrong simplified filter: " + simplified, simplified instanceof NoneFilter);
}
Also used : PrismContext(com.evolveum.midpoint.prism.PrismContext) Test(org.testng.annotations.Test)

Example 77 with PrismContext

use of com.evolveum.midpoint.prism.PrismContext in project midpoint by Evolveum.

the class TestFilterSimplifier method test110AndLevel1WithoutNone.

@Test
public void test110AndLevel1WithoutNone() throws Exception {
    System.out.println("===[ test110AndLevel1WithoutNone ]===");
    // GIVEN
    PrismContext prismContext = PrismTestUtil.getPrismContext();
    // WHEN
    ObjectFilter filter = QueryBuilder.queryFor(UserType.class, prismContext).all().and().undefined().buildFilter();
    System.out.println("Original filter:\n" + filter.debugDump());
    // THEN
    ObjectFilter simplified = ObjectQueryUtil.simplify(filter);
    System.out.println("Simplified filter:\n" + DebugUtil.debugDump(simplified));
    assertTrue("Wrong simplified filter: " + simplified, simplified == null || simplified instanceof AllFilter);
}
Also used : PrismContext(com.evolveum.midpoint.prism.PrismContext) Test(org.testng.annotations.Test)

Example 78 with PrismContext

use of com.evolveum.midpoint.prism.PrismContext in project midpoint by Evolveum.

the class TestFilterSimplifier method test300NotAll.

@Test
public void test300NotAll() throws Exception {
    System.out.println("===[ test300NotAll ]===");
    // GIVEN
    PrismContext prismContext = PrismTestUtil.getPrismContext();
    // WHEN
    ObjectFilter filter = QueryBuilder.queryFor(UserType.class, prismContext).not().all().buildFilter();
    System.out.println("Original filter:\n" + filter.debugDump());
    // THEN
    ObjectFilter simplified = ObjectQueryUtil.simplify(filter);
    System.out.println("Simplified filter:\n" + DebugUtil.debugDump(simplified));
    assertTrue("Wrong simplified filter: " + simplified, simplified instanceof NoneFilter);
}
Also used : PrismContext(com.evolveum.midpoint.prism.PrismContext) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test)

Example 79 with PrismContext

use of com.evolveum.midpoint.prism.PrismContext in project midpoint by Evolveum.

the class TestFilterSimplifier method test500ExistsAll.

@Test
public void test500ExistsAll() throws Exception {
    System.out.println("===[ test500ExistsAll ]===");
    // GIVEN
    PrismContext prismContext = PrismTestUtil.getPrismContext();
    // WHEN
    ObjectFilter filter = QueryBuilder.queryFor(UserType.class, prismContext).exists(UserType.F_ASSIGNMENT).all().buildFilter();
    System.out.println("Original filter:\n" + filter.debugDump());
    // THEN
    ObjectFilter simplified = ObjectQueryUtil.simplify(filter);
    System.out.println("Simplified filter:\n" + DebugUtil.debugDump(simplified));
    assertTrue("Wrong simplified filter: " + simplified, simplified instanceof ExistsFilter);
    ExistsFilter existsSimplified = (ExistsFilter) simplified;
    assertEquals("Wrong simplified filter path", new ItemPath(UserType.F_ASSIGNMENT), existsSimplified.getFullPath());
    assertTrue("Wrong simplified filter subfilter: " + existsSimplified.getFilter(), ObjectQueryUtil.isAll(existsSimplified.getFilter()));
}
Also used : PrismContext(com.evolveum.midpoint.prism.PrismContext) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) Test(org.testng.annotations.Test)

Example 80 with PrismContext

use of com.evolveum.midpoint.prism.PrismContext in project midpoint by Evolveum.

the class TestAdHocCertification method test020ModifyIndigo.

@Test
public void test020ModifyIndigo() throws Exception {
    final String TEST_NAME = "test020ModifyIndigo";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(TestAdHocCertification.class.getName() + "." + TEST_NAME);
    task.setOwner(userAdministrator.asPrismObject());
    OperationResult result = task.getResult();
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    @SuppressWarnings({ "unchecked", "raw" }) ObjectDelta<UserType> delta = (ObjectDelta<UserType>) DeltaBuilder.deltaFor(UserType.class, prismContext).item(UserType.F_DESCRIPTION).replace("new description").item(UserType.F_ACTIVATION, ActivationType.F_ADMINISTRATIVE_STATUS).replace(ActivationStatusType.DISABLED).asObjectDelta(USER_INDIGO_OID);
    executeChanges(delta, null, task, result);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    SearchResultList<PrismObject<AccessCertificationCampaignType>> campaigns = repositoryService.searchObjects(AccessCertificationCampaignType.class, null, null, result);
    assertEquals("Wrong # of campaigns", 2, campaigns.size());
    AccessCertificationCampaignType campaign = campaigns.stream().filter(c -> MODIFICATION_CERT_DEF_OID.equals(c.asObjectable().getDefinitionRef().getOid())).findFirst().orElseThrow(() -> new AssertionError("No modification-triggered campaign")).asObjectable();
    campaign = getCampaignWithCases(campaign.getOid());
    display("campaign", campaign);
    // beware, maybe not all details would match (in the future) - then adapt this test
    assertAfterCampaignStart(campaign, modificationCertificationDefinition, 1);
    // no cases, no problems
    assertPercentComplete(campaign, 0, 0, 0);
}
Also used : DirtiesContext(org.springframework.test.annotation.DirtiesContext) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) DeltaBuilder(com.evolveum.midpoint.prism.delta.builder.DeltaBuilder) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) PrismObject(com.evolveum.midpoint.prism.PrismObject) DebugUtil(com.evolveum.midpoint.util.DebugUtil) Task(com.evolveum.midpoint.task.api.Task) File(java.io.File) IntegrationTestTools.display(com.evolveum.midpoint.test.IntegrationTestTools.display) SearchResultList(com.evolveum.midpoint.schema.SearchResultList) PrismContext(com.evolveum.midpoint.prism.PrismContext) ContextConfiguration(org.springframework.test.context.ContextConfiguration) TestUtil(com.evolveum.midpoint.test.util.TestUtil) AssertJUnit.assertEquals(org.testng.AssertJUnit.assertEquals) Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PrismObject(com.evolveum.midpoint.prism.PrismObject) ObjectDelta(com.evolveum.midpoint.prism.delta.ObjectDelta) Test(org.testng.annotations.Test)

Aggregations

PrismContext (com.evolveum.midpoint.prism.PrismContext)104 Test (org.testng.annotations.Test)59 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)15 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)15 QName (javax.xml.namespace.QName)15 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)13 Task (com.evolveum.midpoint.task.api.Task)11 SchemaRegistry (com.evolveum.midpoint.prism.schema.SchemaRegistry)10 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)10 PrismObject (com.evolveum.midpoint.prism.PrismObject)9 SystemException (com.evolveum.midpoint.util.exception.SystemException)9 File (java.io.File)8 PrismPropertyDefinition (com.evolveum.midpoint.prism.PrismPropertyDefinition)7 ArrayList (java.util.ArrayList)7 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)6 AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)6 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)6 Protector (com.evolveum.midpoint.prism.crypto.Protector)5 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)5 MidPointApplication (com.evolveum.midpoint.web.security.MidPointApplication)5