Search in sources :

Example 1 with PrismContext

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

the class TestProtectedString method testParseProtectedStringEncrypted.

@Test
public void testParseProtectedStringEncrypted() throws Exception {
    final String TEST_NAME = "testParseProtectedStringEncrypted";
    displayTestTitle(TEST_NAME);
    // GIVEN
    Protector protector = PrismInternalTestUtil.createProtector(XMLCipher.AES_128);
    ProtectedStringType protectedStringType = protector.encryptString("salalala");
    PrismContext prismContext = PrismTestUtil.getPrismContext();
    // WHEN
    MapXNode protectedStringTypeXNode = ((PrismContextImpl) prismContext).getBeanMarshaller().marshalProtectedDataType(protectedStringType, null);
    System.out.println("Protected string type XNode: " + protectedStringTypeXNode.debugDump());
    // THEN
    ProtectedStringType unmarshalled = new ProtectedStringType();
    XNodeProcessorUtil.parseProtectedType(unmarshalled, protectedStringTypeXNode, prismContext, ParsingContext.createDefault());
    System.out.println("Unmarshalled value: " + unmarshalled);
    assertEquals("Unmarshalled value differs from the original", protectedStringType, unmarshalled);
}
Also used : PrismContext(com.evolveum.midpoint.prism.PrismContext) MapXNode(com.evolveum.midpoint.prism.xnode.MapXNode) ProtectedStringType(com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType) TestProtector(com.evolveum.midpoint.prism.crypto.TestProtector) Protector(com.evolveum.midpoint.prism.crypto.Protector) Test(org.testng.annotations.Test)

Example 2 with PrismContext

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

the class TestProtectedString method testParseProtectedStringHashed.

@Test
public void testParseProtectedStringHashed() throws Exception {
    final String TEST_NAME = "testParseProtectedStringHashed";
    displayTestTitle(TEST_NAME);
    // GIVEN
    ProtectedStringType protectedStringType = new ProtectedStringType();
    protectedStringType.setClearValue("blabla");
    Protector protector = PrismInternalTestUtil.createProtector(XMLCipher.AES_128);
    protector.hash(protectedStringType);
    PrismContext prismContext = PrismTestUtil.getPrismContext();
    // WHEN
    MapXNode protectedStringTypeXNode = ((PrismContextImpl) prismContext).getBeanMarshaller().marshalProtectedDataType(protectedStringType, null);
    System.out.println("Protected string type XNode: " + protectedStringTypeXNode.debugDump());
    // THEN
    ProtectedStringType unmarshalled = new ProtectedStringType();
    XNodeProcessorUtil.parseProtectedType(unmarshalled, protectedStringTypeXNode, prismContext, ParsingContext.createDefault());
    System.out.println("Unmarshalled value: " + unmarshalled);
    assertEquals("Unmarshalled value differs from the original", protectedStringType, unmarshalled);
}
Also used : PrismContext(com.evolveum.midpoint.prism.PrismContext) MapXNode(com.evolveum.midpoint.prism.xnode.MapXNode) ProtectedStringType(com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType) TestProtector(com.evolveum.midpoint.prism.crypto.TestProtector) Protector(com.evolveum.midpoint.prism.crypto.Protector) Test(org.testng.annotations.Test)

Example 3 with PrismContext

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

the class TestRefinedSchema method testParseFromResourceSimple.

@Test
public void testParseFromResourceSimple() throws JAXBException, SchemaException, SAXException, IOException {
    System.out.println("\n===[ testParseFromResourceSimple ]===\n");
    // GIVEN
    PrismContext prismContext = createInitializedPrismContext();
    PrismObject<ResourceType> resource = prismContext.parseObject(RESOURCE_SIMPLE_FILE);
    ResourceType resourceType = resource.asObjectable();
    // WHEN
    RefinedResourceSchema rSchema = RefinedResourceSchemaImpl.parse(resourceType, prismContext);
    // THEN
    assertNotNull("Refined schema is null", rSchema);
    System.out.println("Refined schema");
    System.out.println(rSchema.debugDump());
    assertRefinedSchema(resourceType, rSchema, null, LayerType.SCHEMA, false);
}
Also used : PrismContext(com.evolveum.midpoint.prism.PrismContext) ResourceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType) Test(org.testng.annotations.Test)

Example 4 with PrismContext

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

the class TestDiffEquals method testAssignmentEquivalent.

@Test
public void testAssignmentEquivalent() throws Exception {
    System.out.println("\n\n===[ testAssignmentEquivalent ]===\n");
    PrismContext prismContext = PrismTestUtil.getPrismContext();
    AssignmentType a1 = new AssignmentType(prismContext);
    ActivationType a1a = new ActivationType(prismContext);
    a1a.setValidFrom(XmlTypeConverter.createXMLGregorianCalendar(new Date()));
    a1a.setEffectiveStatus(ActivationStatusType.ENABLED);
    a1.setActivation(a1a);
    AssignmentType a2 = new AssignmentType(prismContext);
    ActivationType a2a = new ActivationType(prismContext);
    a2a.setEffectiveStatus(ActivationStatusType.ENABLED);
    a2.setActivation(a2a);
    // WHEN
    assertFalse(a1.equals(a2));
    // a bit redundant
    assertFalse(a1.asPrismContainerValue().equivalent(a2.asPrismContainerValue()));
    assertFalse(a2.equals(a1));
    // a bit redundant
    assertFalse(a2.asPrismContainerValue().equivalent(a1.asPrismContainerValue()));
}
Also used : PrismContext(com.evolveum.midpoint.prism.PrismContext) ActivationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationType) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType) Date(java.util.Date) Test(org.testng.annotations.Test)

Example 5 with PrismContext

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

the class SearchPanel method searchPerformed.

void searchPerformed(AjaxRequestTarget target) {
    PageBase page = (PageBase) getPage();
    PrismContext ctx = page.getPrismContext();
    Search search = getModelObject();
    ObjectQuery query = search.createObjectQuery(ctx);
    LOG.debug("Created query: {}", query);
    searchPerformed(query, target);
}
Also used : PrismContext(com.evolveum.midpoint.prism.PrismContext) PageBase(com.evolveum.midpoint.gui.api.page.PageBase) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery)

Aggregations

PrismContext (com.evolveum.midpoint.prism.PrismContext)137 Test (org.testng.annotations.Test)62 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)34 PrismObject (com.evolveum.midpoint.prism.PrismObject)27 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)26 Task (com.evolveum.midpoint.task.api.Task)21 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)19 QName (javax.xml.namespace.QName)19 ArrayList (java.util.ArrayList)16 RepositoryService (com.evolveum.midpoint.repo.api.RepositoryService)13 Trace (com.evolveum.midpoint.util.logging.Trace)12 TraceManager (com.evolveum.midpoint.util.logging.TraceManager)12 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)12 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)11 com.evolveum.midpoint.xml.ns._public.common.common_3 (com.evolveum.midpoint.xml.ns._public.common.common_3)11 Autowired (org.springframework.beans.factory.annotation.Autowired)11 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)10 Collectors (java.util.stream.Collectors)10 NotNull (org.jetbrains.annotations.NotNull)10 PrismTestUtil.getPrismContext (com.evolveum.midpoint.prism.util.PrismTestUtil.getPrismContext)9