From 634a2c7d64b7dd273908c3634c9e0ea364fc7545 Mon Sep 17 00:00:00 2001 From: Radovan Semancik Date: Tue, 13 Jun 2017 10:15:30 +0200 Subject: [PATCH] Fixing big bug concerning refined schema. Fixing several tests. --- .../icf/dummy/resource/DummyResource.java | 4 ++ ...LayerRefinedObjectClassDefinitionImpl.java | 6 ++ .../RefinedObjectClassDefinition.java | 1 + .../refinery/RefinedResourceSchema.java | 5 +- .../refinery/RefinedResourceSchemaImpl.java | 55 +++++++++------- .../common/refinery/TestRefinedSchema.java | 55 ++++++++++------ .../ObjectClassComplexTypeDefinition.java | 7 ++- .../ObjectClassComplexTypeDefinitionImpl.java | 14 +++++ .../sync/SynchronizeAccountResultHandler.java | 25 ++++---- .../midpoint/model/impl/util/Utils.java | 2 +- .../src/test/resources/logback-test.xml | 1 + .../impl/dummy/AbstractBasicDummyTest.java | 46 ++++++++++++-- .../impl/dummy/TestDummyExtra.java | 5 ++ .../impl/dummy/TestDummyIncomplete.java | 5 ++ ...esource-dummy-schemaless-static-schema.xml | 62 +++++++++++++++++++ .../connid/ConnectorInstanceConnIdImpl.java | 6 +- .../test/AbstractIntegrationTest.java | 36 ++++++++--- .../midpoint/test/DummyResourceContoller.java | 10 +++ .../AbstractAdLdapMultidomainTest.java | 9 ++- .../testing/conntest/AbstractLdapTest.java | 2 +- .../midpoint/testing/conntest/AdUtils.java | 25 +++++++- .../testing/conntest/TestAdLdapChimera.java | 12 ++-- .../ad-ldap-multidomain/resource-chimera.xml | 3 +- .../resources/common/system-configuration.xml | 4 +- .../src/test/resources/logback-test.xml | 7 ++- .../testing/consistency/ConsistencyTest.java | 32 +++++----- 26 files changed, 336 insertions(+), 103 deletions(-) diff --git a/icf-connectors/dummy-resource/src/main/java/com/evolveum/icf/dummy/resource/DummyResource.java b/icf-connectors/dummy-resource/src/main/java/com/evolveum/icf/dummy/resource/DummyResource.java index 986481202ec..3b7f0303667 100644 --- a/icf-connectors/dummy-resource/src/main/java/com/evolveum/icf/dummy/resource/DummyResource.java +++ b/icf-connectors/dummy-resource/src/main/java/com/evolveum/icf/dummy/resource/DummyResource.java @@ -409,6 +409,10 @@ public void addAuxiliaryObjectClass(String name, DummyObjectClass objectClass) { auxiliaryObjectClassMap.put(name, objectClass); } + public int getNumberOfObjectclasses() { + return 4 + auxiliaryObjectClassMap.size(); + } + public Collection listAccounts() throws ConnectException, FileNotFoundException, SchemaViolationException, ConflictException { checkBlockOperations(); breakIt(getBreakMode, "get"); diff --git a/infra/common/src/main/java/com/evolveum/midpoint/common/refinery/LayerRefinedObjectClassDefinitionImpl.java b/infra/common/src/main/java/com/evolveum/midpoint/common/refinery/LayerRefinedObjectClassDefinitionImpl.java index 6542adc5c1a..295dfa55f3a 100644 --- a/infra/common/src/main/java/com/evolveum/midpoint/common/refinery/LayerRefinedObjectClassDefinitionImpl.java +++ b/infra/common/src/main/java/com/evolveum/midpoint/common/refinery/LayerRefinedObjectClassDefinitionImpl.java @@ -605,4 +605,10 @@ public void revive(PrismContext prismContext) { refinedObjectClassDefinition.revive(prismContext); } + @Override + public String toString() { + return "LROCDef("+layer+": " + + refinedObjectClassDefinition + ")"; + } + } diff --git a/infra/common/src/main/java/com/evolveum/midpoint/common/refinery/RefinedObjectClassDefinition.java b/infra/common/src/main/java/com/evolveum/midpoint/common/refinery/RefinedObjectClassDefinition.java index d762ec6ec43..9a8fde594b8 100644 --- a/infra/common/src/main/java/com/evolveum/midpoint/common/refinery/RefinedObjectClassDefinition.java +++ b/infra/common/src/main/java/com/evolveum/midpoint/common/refinery/RefinedObjectClassDefinition.java @@ -139,6 +139,7 @@ default PrismObject createBlankShadow() { ResourceShadowDiscriminator getShadowDiscriminator(); + @Override boolean matches(ShadowType shadowType); //endregion diff --git a/infra/common/src/main/java/com/evolveum/midpoint/common/refinery/RefinedResourceSchema.java b/infra/common/src/main/java/com/evolveum/midpoint/common/refinery/RefinedResourceSchema.java index dd113518ab5..08b290ca350 100644 --- a/infra/common/src/main/java/com/evolveum/midpoint/common/refinery/RefinedResourceSchema.java +++ b/infra/common/src/main/java/com/evolveum/midpoint/common/refinery/RefinedResourceSchema.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2016 Evolveum + * Copyright (c) 2010-2017 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,6 @@ import com.evolveum.midpoint.prism.PrismContext; import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.PrismObjectDefinition; -import com.evolveum.midpoint.prism.schema.PrismSchema; import com.evolveum.midpoint.schema.ResourceShadowDiscriminator; import com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition; import com.evolveum.midpoint.schema.processor.ResourceSchema; @@ -97,6 +96,6 @@ static RefinedResourceSchema getRefinedSchema(PrismObject resource static ResourceSchema getResourceSchema(PrismObject resource, PrismContext prismContext) throws SchemaException { - return RefinedResourceSchemaImpl.getRefinedSchema(resource, prismContext); + return RefinedResourceSchemaImpl.getResourceSchema(resource, prismContext); } } diff --git a/infra/common/src/main/java/com/evolveum/midpoint/common/refinery/RefinedResourceSchemaImpl.java b/infra/common/src/main/java/com/evolveum/midpoint/common/refinery/RefinedResourceSchemaImpl.java index e3d70b2b1b6..cc5101e6dcd 100644 --- a/infra/common/src/main/java/com/evolveum/midpoint/common/refinery/RefinedResourceSchemaImpl.java +++ b/infra/common/src/main/java/com/evolveum/midpoint/common/refinery/RefinedResourceSchemaImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2016 Evolveum + * Copyright (c) 2010-2017 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,25 +35,33 @@ import java.util.*; /** + * TODO: this whole class would benefit from more refactoring. + * TODO: especially the parsing part. + * * @author semancik - * + * @author mederly */ public class RefinedResourceSchemaImpl implements RefinedResourceSchema { private static final String USER_DATA_KEY_PARSED_RESOURCE_SCHEMA = RefinedResourceSchema.class.getName()+".parsedResourceSchema"; private static final String USER_DATA_KEY_REFINED_SCHEMA = RefinedResourceSchema.class.getName()+".refinedSchema"; - // TODO really don't remember why we include originalResourceSchema here instead of simply extending ResourceSchemaImpl ... - // TODO Maybe that's because we need to create new RefinedResourceSchema(s) based on existing ResourceSchema(s)? + // Original resource schema is there to make parsing easier. + // But it is also useful in some cases, e.g. we do not need to pass both refined schema and + // original schema as a metod parameter. private ResourceSchema originalResourceSchema; + // This object contains the real data of the refined schema + private ResourceSchema resourceSchema; + private RefinedResourceSchemaImpl(@NotNull ResourceSchema originalResourceSchema) { this.originalResourceSchema = originalResourceSchema; + this.resourceSchema = new ResourceSchemaImpl(originalResourceSchema.getNamespace(), originalResourceSchema.getPrismContext()); } @Override public List getRefinedDefinitions() { - return originalResourceSchema.getDefinitions(RefinedObjectClassDefinition.class); + return resourceSchema.getDefinitions(RefinedObjectClassDefinition.class); } @Override @@ -401,6 +409,7 @@ public static RefinedResourceSchema parse(ResourceType resourceType, PrismContex // return false; // } + // TODO: The whole parsing is a big mess. TODO: refactor parsing private static void parseObjectTypeDefsFromSchemaHandling(RefinedResourceSchemaImpl rSchema, ResourceType resourceType, SchemaHandlingType schemaHandling, Collection resourceObjectTypeDefs, ShadowKindType impliedKind, PrismContext prismContext, String contextDescription) throws SchemaException { @@ -466,106 +475,106 @@ private static void parseObjectTypesFromSchema(RefinedResourceSchemaImpl rSchema //endregion private void add(RefinedObjectClassDefinition rOcDef) { - ((ResourceSchemaImpl) originalResourceSchema).add(rOcDef); // TODO FIXME + ((ResourceSchemaImpl) resourceSchema).add(rOcDef); } //region Delegations @Override public ObjectClassComplexTypeDefinition findObjectClassDefinition(QName objectClassQName) { - return originalResourceSchema.findObjectClassDefinition(objectClassQName); + return resourceSchema.findObjectClassDefinition(objectClassQName); } @Override public ObjectClassComplexTypeDefinition findObjectClassDefinition(ShadowKindType kind, String intent) { - return originalResourceSchema.findObjectClassDefinition(kind, intent); + return resourceSchema.findObjectClassDefinition(kind, intent); } @Override public ObjectClassComplexTypeDefinition findDefaultObjectClassDefinition(ShadowKindType kind) { - return originalResourceSchema.findDefaultObjectClassDefinition(kind); + return resourceSchema.findDefaultObjectClassDefinition(kind); } @Override public String getNamespace() { - return originalResourceSchema.getNamespace(); + return resourceSchema.getNamespace(); } @Override @NotNull public Collection getDefinitions() { - return originalResourceSchema.getDefinitions(); + return resourceSchema.getDefinitions(); } @Override @NotNull public List getDefinitions(@NotNull Class type) { - return originalResourceSchema.getDefinitions(type); + return resourceSchema.getDefinitions(type); } @Override public PrismContext getPrismContext() { - return originalResourceSchema.getPrismContext(); + return resourceSchema.getPrismContext(); } @Override @NotNull public Document serializeToXsd() throws SchemaException { - return originalResourceSchema.serializeToXsd(); + return resourceSchema.serializeToXsd(); } @Override public boolean isEmpty() { - return originalResourceSchema.isEmpty(); + return resourceSchema.isEmpty(); } @NotNull @Override public List findItemDefinitionsByCompileTimeClass( @NotNull Class compileTimeClass, @NotNull Class definitionClass) { - return originalResourceSchema.findItemDefinitionsByCompileTimeClass(compileTimeClass, definitionClass); + return resourceSchema.findItemDefinitionsByCompileTimeClass(compileTimeClass, definitionClass); } @Nullable @Override public TD findTypeDefinitionByCompileTimeClass(@NotNull Class compileTimeClass, @NotNull Class definitionClass) { - return originalResourceSchema.findTypeDefinitionByCompileTimeClass(compileTimeClass, definitionClass); + return resourceSchema.findTypeDefinitionByCompileTimeClass(compileTimeClass, definitionClass); } @Override @Nullable public TD findTypeDefinitionByType(@NotNull QName typeName, @NotNull Class definitionClass) { - return originalResourceSchema.findTypeDefinitionByType(typeName, definitionClass); + return resourceSchema.findTypeDefinitionByType(typeName, definitionClass); } @Override public String debugDump() { - return originalResourceSchema.debugDump(); + return resourceSchema.debugDump(); } @Override public String debugDump(int indent) { - return originalResourceSchema.debugDump(indent); + return resourceSchema.debugDump(indent); } @Nullable @Override public ID findItemDefinitionByType( @NotNull QName typeName, @NotNull Class definitionType) { - return originalResourceSchema.findItemDefinitionByType(typeName, definitionType); + return resourceSchema.findItemDefinitionByType(typeName, definitionType); } @Override @NotNull public List findItemDefinitionsByElementName(@NotNull QName elementName, @NotNull Class definitionClass) { - return originalResourceSchema.findItemDefinitionsByElementName(elementName, definitionClass); + return resourceSchema.findItemDefinitionsByElementName(elementName, definitionClass); } @NotNull @Override public Collection findTypeDefinitionsByType(@NotNull QName typeName, @NotNull Class definitionClass) { - return originalResourceSchema.findTypeDefinitionsByType(typeName, definitionClass); + return resourceSchema.findTypeDefinitionsByType(typeName, definitionClass); } //endregion diff --git a/infra/common/src/test/java/com/evolveum/midpoint/common/refinery/TestRefinedSchema.java b/infra/common/src/test/java/com/evolveum/midpoint/common/refinery/TestRefinedSchema.java index 5894d977fab..870fb8b9132 100644 --- a/infra/common/src/test/java/com/evolveum/midpoint/common/refinery/TestRefinedSchema.java +++ b/infra/common/src/test/java/com/evolveum/midpoint/common/refinery/TestRefinedSchema.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2016 Evolveum + * Copyright (c) 2010-2017 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,11 +37,13 @@ import org.testng.Assert; import org.testng.AssertJUnit; import org.testng.annotations.BeforeSuite; +import org.testng.annotations.Listeners; import org.testng.annotations.Test; import org.xml.sax.SAXException; import com.evolveum.midpoint.common.ResourceObjectPattern; import com.evolveum.midpoint.prism.Containerable; +import com.evolveum.midpoint.prism.Definition; import com.evolveum.midpoint.prism.ItemDefinition; import com.evolveum.midpoint.prism.PrismContainer; import com.evolveum.midpoint.prism.PrismContainerDefinition; @@ -68,6 +70,7 @@ /** * @author semancik */ +@Listeners({com.evolveum.midpoint.tools.testng.AlphabeticalMethodInterceptor.class}) public class TestRefinedSchema { public static final String TEST_DIR_NAME = "src/test/resources/refinery"; @@ -88,8 +91,8 @@ public void setup() throws SchemaException, SAXException, IOException { } @Test - public void testParseFromResourceComplex() throws Exception { - final String TEST_NAME = "testParseFromResourceComplex"; + public void test010ParseFromResourceComplex() throws Exception { + final String TEST_NAME = "test010ParseFromResourceComplex"; TestUtil.displayTestTile(TEST_NAME); // GIVEN @@ -128,8 +131,9 @@ private void assertLayerRefinedSchema(ResourceType resourceType, RefinedResource } @Test - public void testParseFromResourceSimple() throws JAXBException, SchemaException, SAXException, IOException { - System.out.println("\n===[ testParseFromResourceSimple ]===\n"); + public void test020ParseFromResourceSimple() throws Exception { + final String TEST_NAME = "test020ParseFromResourceSimple"; + TestUtil.displayTestTile(TEST_NAME); // GIVEN PrismContext prismContext = createInitializedPrismContext(); @@ -151,6 +155,15 @@ public void testParseFromResourceSimple() throws JAXBException, SchemaException, private void assertRefinedSchema(ResourceType resourceType, RefinedResourceSchema rSchema, LayerType sourceLayer, LayerType validationLayer, boolean assertEntitlements) { + + assertEquals("Unexpected number of object classes in refined schema", 2, rSchema.getDefinitions().size()); + + for (Definition def: rSchema.getDefinitions()) { + if (!(def instanceof RefinedObjectClassDefinition)) { + AssertJUnit.fail("Non-refined definition sneaked into resource schema: "+def); + } + } + assertFalse("No account definitions", rSchema.getRefinedDefinitions(ShadowKindType.ACCOUNT).isEmpty()); RefinedObjectClassDefinition rAccountDef = rSchema.getRefinedDefinition(ShadowKindType.ACCOUNT, (String)null); @@ -269,8 +282,9 @@ private void assertRefinedToLayer(ResourceAttributeDefinition attrDef, LayerType } @Test - public void testParseAccount() throws JAXBException, SchemaException, SAXException, IOException { - System.out.println("\n===[ testParseAccount ]===\n"); + public void test100ParseAccount() throws Exception { + final String TEST_NAME = "test100ParseAccount"; + TestUtil.displayTestTile(TEST_NAME); // GIVEN PrismContext prismContext = createInitializedPrismContext(); @@ -302,8 +316,9 @@ public void testParseAccount() throws JAXBException, SchemaException, SAXExcepti } @Test - public void testApplyAttributeDefinition() throws JAXBException, SchemaException, SAXException, IOException { - System.out.println("\n===[ testApplyAttributeDefinition ]===\n"); + public void test110ApplyAttributeDefinition() throws Exception { + final String TEST_NAME = "test110ApplyAttributeDefinition"; + TestUtil.displayTestTile(TEST_NAME); // GIVEN PrismContext prismContext = createInitializedPrismContext(); @@ -311,22 +326,24 @@ public void testApplyAttributeDefinition() throws JAXBException, SchemaException PrismObject resource = prismContext.parseObject(RESOURCE_COMPLEX_FILE); RefinedResourceSchema rSchema = RefinedResourceSchemaImpl.parse(resource, prismContext); + System.out.println("Refined schema:"); + System.out.println(rSchema.debugDump(1)); RefinedObjectClassDefinition defaultAccountDefinition = rSchema.getDefaultRefinedDefinition(ShadowKindType.ACCOUNT); assertNotNull("No refined default account definition in "+rSchema, defaultAccountDefinition); System.out.println("Refined account definition:"); - System.out.println(defaultAccountDefinition.debugDump()); + System.out.println(defaultAccountDefinition.debugDump(1)); PrismObject accObject = prismContext.parseObject(new File(TEST_DIR_NAME, "account-jack.xml")); PrismContainer attributesContainer = accObject.findContainer(ShadowType.F_ATTRIBUTES); System.out.println("Attributes container:"); - System.out.println(attributesContainer.debugDump()); + System.out.println(attributesContainer.debugDump(1)); // WHEN attributesContainer.applyDefinition((PrismContainerDefinition)defaultAccountDefinition.toResourceAttributeContainerDefinition(), true); // THEN System.out.println("Parsed account:"); - System.out.println(accObject.debugDump()); + System.out.println(accObject.debugDump(1)); assertAccountShadow(accObject, resource, prismContext); } @@ -376,8 +393,9 @@ private QName getAttrQName(PrismObject resource, String localPart) } @Test - public void testCreateShadow() throws JAXBException, SchemaException, SAXException, IOException { - System.out.println("\n===[ testCreateShadow ]===\n"); + public void test120CreateShadow() throws Exception { + final String TEST_NAME = "test120CreateShadow"; + TestUtil.displayTestTile(TEST_NAME); // GIVEN PrismContext prismContext = createInitializedPrismContext(); @@ -405,8 +423,9 @@ public void testCreateShadow() throws JAXBException, SchemaException, SAXExcepti } @Test - public void testProtectedAccount() throws JAXBException, SchemaException, SAXException, IOException { - System.out.println("\n===[ testProtectedAccount ]===\n"); + public void test130ProtectedAccount() throws Exception { + final String TEST_NAME = "test130ProtectedAccount"; + TestUtil.displayTestTile(TEST_NAME); // GIVEN PrismContext prismContext = createInitializedPrismContext(); @@ -531,8 +550,8 @@ private ResourceAttribute createStringAttribute(QName attrName, String v } @Test - public void testParseFromResourcePosix() throws Exception { - final String TEST_NAME = "testParseFromResourcePosix"; + public void test140ParseFromResourcePosix() throws Exception { + final String TEST_NAME = "test140ParseFromResourcePosix"; TestUtil.displayTestTile(TEST_NAME); // GIVEN diff --git a/infra/schema/src/main/java/com/evolveum/midpoint/schema/processor/ObjectClassComplexTypeDefinition.java b/infra/schema/src/main/java/com/evolveum/midpoint/schema/processor/ObjectClassComplexTypeDefinition.java index 2933b1b912d..1ee48c7fc25 100644 --- a/infra/schema/src/main/java/com/evolveum/midpoint/schema/processor/ObjectClassComplexTypeDefinition.java +++ b/infra/schema/src/main/java/com/evolveum/midpoint/schema/processor/ObjectClassComplexTypeDefinition.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2016 Evolveum + * Copyright (c) 2010-2017 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -196,7 +196,7 @@ default Collection> getAllIdentifiers() boolean isAuxiliary(); /** - * TODO + * TODO: THIS SHOULD NOT BE HERE * @return */ ShadowKindType getKind(); @@ -215,7 +215,7 @@ default Collection> getAllIdentifiers() boolean isDefaultInAKind(); /** - * TODO + * TODO: THIS SHOULD NOT BE HERE * @return */ String getIntent(); @@ -237,4 +237,5 @@ default ObjectQuery createShadowSearchQuery(String resourceOid) throws SchemaExc @NotNull ObjectClassComplexTypeDefinition clone(); + boolean matches(ShadowType shadowType); } diff --git a/infra/schema/src/main/java/com/evolveum/midpoint/schema/processor/ObjectClassComplexTypeDefinitionImpl.java b/infra/schema/src/main/java/com/evolveum/midpoint/schema/processor/ObjectClassComplexTypeDefinitionImpl.java index f0b5d0cf450..322ba45e586 100644 --- a/infra/schema/src/main/java/com/evolveum/midpoint/schema/processor/ObjectClassComplexTypeDefinitionImpl.java +++ b/infra/schema/src/main/java/com/evolveum/midpoint/schema/processor/ObjectClassComplexTypeDefinitionImpl.java @@ -18,7 +18,10 @@ import com.evolveum.midpoint.prism.ComplexTypeDefinitionImpl; import com.evolveum.midpoint.prism.ItemDefinition; import com.evolveum.midpoint.prism.PrismContext; +import com.evolveum.midpoint.util.QNameUtil; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType; +import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; + import org.jetbrains.annotations.NotNull; import javax.xml.namespace.QName; @@ -191,6 +194,17 @@ public ResourceAttributeDefinition createAttributeDefinition(String local return createAttributeDefinition(name,typeName); } + @Override + public boolean matches(ShadowType shadowType) { + if (shadowType == null) { + return false; + } + if (!QNameUtil.match(getTypeName(), shadowType.getObjectClass())) { + return false; + } + return true; + } + /** * This may not be really "clean" as it actually does two steps instead of one. But it is useful. */ diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/sync/SynchronizeAccountResultHandler.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/sync/SynchronizeAccountResultHandler.java index ab22bbb354a..2dfcabf88be 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/sync/SynchronizeAccountResultHandler.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/sync/SynchronizeAccountResultHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2013 Evolveum + * Copyright (c) 2010-2017 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -59,18 +59,18 @@ public class SynchronizeAccountResultHandler extends AbstractSearchIterativeResu private String resourceOid; private ThreadLocal resourceWorkingCopy = new ThreadLocal<>(); // because PrismContainer is not thread safe even for reading, each thread must have its own copy private ResourceType resourceReadOnly; // this is a "master copy", not to be touched by getters - its content is copied into resourceWorkingCopy content when needed - private ObjectClassComplexTypeDefinition objectClass; + private ObjectClassComplexTypeDefinition objectClassDef; private QName sourceChannel; private boolean forceAdd; - public SynchronizeAccountResultHandler(ResourceType resource, ObjectClassComplexTypeDefinition objectClass, + public SynchronizeAccountResultHandler(ResourceType resource, ObjectClassComplexTypeDefinition objectClassDef, String processShortName, Task coordinatorTask, ResourceObjectChangeListener objectChangeListener, TaskManager taskManager) { super(coordinatorTask, SynchronizeAccountResultHandler.class.getName(), processShortName, "from "+resource, taskManager); this.objectChangeListener = objectChangeListener; this.resourceReadOnly = resource; this.resourceOid = resource.getOid(); - this.objectClass = objectClass; + this.objectClassDef = objectClassDef; forceAdd = false; setRecordIterationStatistics(false); // we do statistics ourselves in handler, because in case of reconciliation // we are not called via AbstractSearchIterativeResultHandler.processRequest @@ -106,7 +106,7 @@ public ResourceType getResourceWorkingCopy() { } public ObjectClassComplexTypeDefinition getObjectClass() { - return objectClass; + return objectClassDef; } /* @@ -139,18 +139,21 @@ protected boolean handleObject(PrismObject accountShadow, Task worke protected boolean handleObjectInternal(PrismObject accountShadow, Task workerTask, OperationResult result) { + if (LOGGER.isTraceEnabled()) { + LOGGER.trace("{} considering object:\n{}", getProcessShortNameCapitalized(), accountShadow.debugDump(1)); + } + ShadowType newShadowType = accountShadow.asObjectable(); if (newShadowType.isProtectedObject() != null && newShadowType.isProtectedObject()) { - LOGGER.trace("{} skipping {} because it is protected", new Object[]{ - getProcessShortNameCapitalized(), accountShadow}); + LOGGER.trace("{} skipping {} because it is protected", + getProcessShortNameCapitalized(), accountShadow); result.recordStatus(OperationResultStatus.NOT_APPLICABLE, "Skipped because it is protected"); return true; } - if (objectClass != null && (objectClass instanceof RefinedObjectClassDefinition) - && !((RefinedObjectClassDefinition) objectClass).matches(newShadowType)) { - LOGGER.trace("{} skipping {} because it does not match objectClass/kind/intent", new Object[]{ - getProcessShortNameCapitalized(), accountShadow}); + if (objectClassDef != null && !objectClassDef.matches(newShadowType)) { + LOGGER.trace("{} skipping {} because it does not match objectClass/kind/intent specified in {}", + getProcessShortNameCapitalized(), accountShadow, objectClassDef); result.recordStatus(OperationResultStatus.NOT_APPLICABLE, "Skipped because it does not match objectClass/kind/intent"); return true; } diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/util/Utils.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/util/Utils.java index 0a350d40bf1..6952ac6b6f3 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/util/Utils.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/util/Utils.java @@ -384,7 +384,7 @@ private static ObjectClassComplexTypeDefinition determineObjectClassInternal( if (kind == null && intent == null && objectclass != null) { // Return generic object class definition from resource schema. No kind/intent means that we want // to process all kinds and intents in the object class. - ObjectClassComplexTypeDefinition objectClassDefinition = refinedSchema.findObjectClassDefinition(objectclass); + ObjectClassComplexTypeDefinition objectClassDefinition = refinedSchema.getOriginalResourceSchema().findObjectClassDefinition(objectclass); if (objectClassDefinition == null) { throw new SchemaException("No object class "+objectclass+" in the schema for "+source); } diff --git a/model/model-intest/src/test/resources/logback-test.xml b/model/model-intest/src/test/resources/logback-test.xml index cc4dca6ceb7..4ce5071bb16 100644 --- a/model/model-intest/src/test/resources/logback-test.xml +++ b/model/model-intest/src/test/resources/logback-test.xml @@ -98,6 +98,7 @@ + diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/AbstractBasicDummyTest.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/AbstractBasicDummyTest.java index d1ae1cfc26a..481676133cf 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/AbstractBasicDummyTest.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/AbstractBasicDummyTest.java @@ -52,6 +52,7 @@ import com.evolveum.midpoint.common.refinery.RefinedResourceSchema; import com.evolveum.midpoint.common.refinery.RefinedResourceSchemaImpl; import com.evolveum.midpoint.prism.Containerable; +import com.evolveum.midpoint.prism.Definition; import com.evolveum.midpoint.prism.PrismContainer; import com.evolveum.midpoint.prism.PrismContainerDefinition; import com.evolveum.midpoint.prism.PrismContext; @@ -146,6 +147,10 @@ protected MatchingRule getUidMatchingRule() { protected boolean isAvoidDuplicateValues() { return false; } + + protected int getExpectedRefinedSchemaDefinitions() { + return dummyResource.getNumberOfObjectclasses(); + } @AfterClass public static void assertCleanShutdown() throws Exception { @@ -531,12 +536,45 @@ public void test023RefinedSchema() throws Exception { accountDef.findAttributeDefinition(new QName(SchemaConstants.NS_ICF_SCHEMA, "password"))); rememberRefinedResourceSchema(refinedSchema); + + for (Definition def: refinedSchema.getDefinitions()) { + if (!(def instanceof RefinedObjectClassDefinition)) { + fail("Non-refined definition sneaked into resource schema: "+def); + } + } + + assertEquals("Unexpected number of schema definitions", getExpectedRefinedSchemaDefinitions(), refinedSchema.getDefinitions().size()); + assertSteadyResource(); } + + /** + * Make sure that the refined schema haven't destroyed cached resource schema. + * Also make sure that the caching in object's user data works well. + */ + @Test + public void test024ParsedSchemaAgain() throws Exception { + final String TEST_NAME = "test024ParsedSchemaAgain"; + TestUtil.displayTestTile(TEST_NAME); + // GIVEN + // THEN + // The returned type should have the schema pre-parsed + assertNotNull(RefinedResourceSchemaImpl.hasParsedSchema(resourceType)); + + // Also test if the utility method returns the same thing + ResourceSchema returnedSchema = RefinedResourceSchemaImpl.getResourceSchema(resourceType, prismContext); + + display("Parsed resource schema", returnedSchema); + assertSchemaSanity(returnedSchema, resourceType); + + assertResourceSchemaUnchanged(returnedSchema); + assertSteadyResource(); + } + @Test - public void test024Capabilities() throws Exception { - final String TEST_NAME = "test024Capabilities"; + public void test028Capabilities() throws Exception { + final String TEST_NAME = "test028Capabilities"; TestUtil.displayTestTile(TEST_NAME); // GIVEN @@ -617,8 +655,8 @@ protected void assertNativeCredentialsCapability(CredentialsCapabilityType capCr * Check if the cached native capabilities were properly stored in the repo */ @Test - public void test025CapabilitiesRepo() throws Exception { - final String TEST_NAME = "test025CapabilitiesRepo"; + public void test029CapabilitiesRepo() throws Exception { + final String TEST_NAME = "test029CapabilitiesRepo"; TestUtil.displayTestTile(TEST_NAME); // GIVEN diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyExtra.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyExtra.java index 3ee4fb3ae2c..a8d6e070ff0 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyExtra.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyExtra.java @@ -85,6 +85,11 @@ protected void extraDummyResourceInit() throws Exception { dummyResourceCtl.addAttrDef(accountObjectClass, DUMMY_ACCOUNT_ATTRIBUTE_MATE_NAME, String.class, false, true); } + @Override + protected int getExpectedRefinedSchemaDefinitions() { + return super.getExpectedRefinedSchemaDefinitions() + 1; + } + @Override protected void assertSchemaSanity(ResourceSchema resourceSchema, ResourceType resourceType) throws Exception { // schema is extended, displayOrders are changed diff --git a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyIncomplete.java b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyIncomplete.java index 355c11c1143..efb371069f8 100644 --- a/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyIncomplete.java +++ b/provisioning/provisioning-impl/src/test/java/com/evolveum/midpoint/provisioning/impl/dummy/TestDummyIncomplete.java @@ -58,6 +58,11 @@ protected File getResourceDummyFilename() { return RESOURCE_DUMMY_FILE; } + @Override + protected int getExpectedRefinedSchemaDefinitions() { + return super.getExpectedRefinedSchemaDefinitions() + 1; + } + @Override protected void assertNativeCredentialsCapability(CredentialsCapabilityType capCred) { PasswordCapabilityType passwordCapabilityType = capCred.getPassword(); diff --git a/provisioning/provisioning-impl/src/test/resources/dummy/dummy-schemaless/resource-dummy-schemaless-static-schema.xml b/provisioning/provisioning-impl/src/test/resources/dummy/dummy-schemaless/resource-dummy-schemaless-static-schema.xml index a85598b320a..6f1f8d655e9 100644 --- a/provisioning/provisioning-impl/src/test/resources/dummy/dummy-schemaless/resource-dummy-schemaless-static-schema.xml +++ b/provisioning/provisioning-impl/src/test/resources/dummy/dummy-schemaless/resource-dummy-schemaless-static-schema.xml @@ -127,6 +127,68 @@ + + + + + icfs:uid + icfs:name + icfs:name + icfs:name + privilege + + + + + + + ConnId UID + 100 + read + + + + + + + ConnId Name + 110 + + + + + + + + + + icfs:uid + icfs:name + icfs:name + icfs:name + org + + + + + + + ConnId UID + 100 + read + + + + + + + ConnId Name + 110 + + + + + diff --git a/provisioning/ucf-impl-connid/src/main/java/com/evolveum/midpoint/provisioning/ucf/impl/connid/ConnectorInstanceConnIdImpl.java b/provisioning/ucf-impl-connid/src/main/java/com/evolveum/midpoint/provisioning/ucf/impl/connid/ConnectorInstanceConnIdImpl.java index 995e8b8379b..51710c0ea48 100644 --- a/provisioning/ucf-impl-connid/src/main/java/com/evolveum/midpoint/provisioning/ucf/impl/connid/ConnectorInstanceConnIdImpl.java +++ b/provisioning/ucf-impl-connid/src/main/java/com/evolveum/midpoint/provisioning/ucf/impl/connid/ConnectorInstanceConnIdImpl.java @@ -652,6 +652,7 @@ private void parseResourceSchema(org.identityconnectors.framework.common.objects legacySchema = detectLegacySchema(icfSchema); } LOGGER.trace("Converting resource schema (legacy mode: {})", legacySchema); + LOGGER.trace("Generating object classes: {}", generateObjectClasses); Set objectClassInfoSet = icfSchema.getObjectClassInfo(); // Let's convert every objectclass in the ICF schema ... @@ -665,7 +666,7 @@ private void parseResourceSchema(org.identityconnectors.framework.common.objects continue; } - LOGGER.trace("Convering object class {} ({})", objectClassInfo.getType(), objectClassXsdName); + LOGGER.trace("Converting object class {} ({})", objectClassInfo.getType(), objectClassXsdName); // ResourceObjectDefinition is a midPpoint way how to represent an // object class. @@ -738,7 +739,7 @@ private void parseResourceSchema(org.identityconnectors.framework.common.objects QName attrXsdType = ConnIdUtil.icfTypeToXsdType(attributeInfo.getType(), false); if (LOGGER.isTraceEnabled()) { - LOGGER.trace("Attr conversion ICF: {}({}) -> XSD: {}({})", + LOGGER.trace(" attr conversion ConnId: {}({}) -> XSD: {}({})", icfName, attributeInfo.getType().getSimpleName(), PrettyPrinter.prettyPrint(attrXsdName), PrettyPrinter.prettyPrint(attrXsdType)); } @@ -866,6 +867,7 @@ private void parseResourceSchema(org.identityconnectors.framework.common.objects ((ObjectClassComplexTypeDefinitionImpl) ocDef).setNamingAttribute(nameDefinition.getName()); ((ObjectClassComplexTypeDefinitionImpl) ocDef).setAuxiliary(objectClassInfo.isAuxiliary()); + LOGGER.trace(" ... converted object class {}: {}", objectClassInfo.getType(), ocDef); } // This is the default for all resources. diff --git a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/AbstractIntegrationTest.java b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/AbstractIntegrationTest.java index 6ceca56fc88..6289370c0e4 100644 --- a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/AbstractIntegrationTest.java +++ b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/AbstractIntegrationTest.java @@ -768,18 +768,36 @@ public PolyString normalize(PolyString original) throws SchemaException { } } } else { - ResourceAttributeDefinition idSecDef = ocDef.getSecondaryIdentifiers().iterator().next(); - PrismProperty idProp = attributesContainer.findProperty(idSecDef.getName()); - assertNotNull("No secondary identifier ("+idSecDef.getName()+") attribute in shadow for "+username, idProp); - if (nameMatchingRule == null) { - assertEquals("Unexpected secondary identifier in shadow for "+username, username, idProp.getRealValue()); - } else { - if (requireNormalizedIdentfiers) { - assertEquals("Unexpected secondary identifier in shadow for "+username, nameMatchingRule.normalize(username), idProp.getRealValue()); + boolean found = false; + String expected = username; + if (requireNormalizedIdentfiers && nameMatchingRule != null) { + expected = nameMatchingRule.normalize(username); + } + List wasValues = new ArrayList<>(); + for (ResourceAttributeDefinition idSecDef: ocDef.getSecondaryIdentifiers()) { + PrismProperty idProp = attributesContainer.findProperty(idSecDef.getName()); + wasValues.addAll(idProp.getRealValues()); + assertNotNull("No secondary identifier ("+idSecDef.getName()+") attribute in shadow for "+username, idProp); + if (nameMatchingRule == null) { + if (username.equals(idProp.getRealValue())) { + found = true; + break; + } } else { - PrismAsserts.assertEquals("Unexpected secondary identifier in shadow for "+username, nameMatchingRule, username, idProp.getRealValue()); + if (requireNormalizedIdentfiers) { + if (expected.equals(idProp.getRealValue())) { + found = true; + break; + } + } else if (nameMatchingRule.match(username, idProp.getRealValue())) { + found = true; + break; + } } } + if (!found) { + fail("Unexpected secondary identifier in shadow for "+username+", expected "+expected+" but was "+wasValues); + } } } diff --git a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/DummyResourceContoller.java b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/DummyResourceContoller.java index 79e0e1d9a11..a25c6744831 100644 --- a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/DummyResourceContoller.java +++ b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/DummyResourceContoller.java @@ -29,6 +29,7 @@ import com.evolveum.midpoint.schema.constants.MidPointConstants; import org.apache.commons.lang.StringUtils; +import org.testng.AssertJUnit; import com.evolveum.icf.dummy.resource.BreakMode; import com.evolveum.icf.dummy.resource.ConflictException; @@ -43,6 +44,7 @@ import com.evolveum.midpoint.common.refinery.RefinedObjectClassDefinition; import com.evolveum.midpoint.common.refinery.RefinedAttributeDefinition; import com.evolveum.midpoint.common.refinery.RefinedResourceSchema; +import com.evolveum.midpoint.prism.Definition; import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.path.ItemPath; import com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition; @@ -297,6 +299,14 @@ public void assertDummyResourceSchemaSanity(ResourceSchema resourceSchema, Resou assertTrue("No members create", membersDef.canAdd()); assertTrue("No members update", membersDef.canModify()); assertTrue("No members read", membersDef.canRead()); + + assertEquals("Unexpected number of schema definitions in "+getName()+" dummy resource", dummyResource.getNumberOfObjectclasses(), resourceSchema.getDefinitions().size()); + + for (Definition def: resourceSchema.getDefinitions()) { + if (def instanceof RefinedObjectClassDefinition) { + AssertJUnit.fail("Refined definition sneaked into resource schema of "+getName()+" dummy resource: "+def); + } + } } public void assertDummyResourceSchemaSanityExtended(ResourceSchema resourceSchema) { diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AbstractAdLdapMultidomainTest.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AbstractAdLdapMultidomainTest.java index 90325c161bb..b330329aea0 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AbstractAdLdapMultidomainTest.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AbstractAdLdapMultidomainTest.java @@ -42,6 +42,7 @@ import org.testng.annotations.Listeners; import org.testng.annotations.Test; +import com.evolveum.midpoint.common.refinery.RefinedResourceSchema; import com.evolveum.midpoint.prism.PrismObject; import com.evolveum.midpoint.prism.delta.ObjectDelta; import com.evolveum.midpoint.prism.delta.PropertyDelta; @@ -55,6 +56,7 @@ import com.evolveum.midpoint.schema.constants.MidPointConstants; import com.evolveum.midpoint.schema.processor.ResourceAttribute; import com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition; +import com.evolveum.midpoint.schema.processor.ResourceSchema; import com.evolveum.midpoint.schema.result.OperationResult; import com.evolveum.midpoint.schema.util.MiscSchemaUtil; import com.evolveum.midpoint.schema.util.ObjectQueryUtil; @@ -120,7 +122,7 @@ public abstract class AbstractAdLdapMultidomainTest extends AbstractLdapTest { private static final String GROUP_MELEE_ISLAND_PIRATES_NAME = "Mêlée Island Pirates"; private static final String GROUP_MELEE_ISLAND_PIRATES_DESCRIPTION = "swashbuckle and loot"; - protected static final int NUMBER_OF_ACCOUNTS = 7; + protected static final int NUMBER_OF_ACCOUNTS = 17; private static final String ASSOCIATION_GROUP_NAME = "group"; private static final String NS_EXTENSION = "http://whatever.com/my"; @@ -323,7 +325,12 @@ public void test020Schema() throws Exception { final String TEST_NAME = "test020Schema"; TestUtil.displayTestTile(this, TEST_NAME); +// IntegrationTestTools.displayXml("Resource XML", resource); accountObjectClassDefinition = AdUtils.assertAdSchema(resource, getAccountObjectClass(), prismContext); + AdUtils.assertExchangeSchema(resource, prismContext); + + ResourceSchema resourceSchema = RefinedResourceSchema.getResourceSchema(resource, prismContext); + assertEquals("Unexpected number of schema definitions (limited by generation constraints)", 5, resourceSchema.getDefinitions().size()); assertLdapConnectorInstances(1); } diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AbstractLdapTest.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AbstractLdapTest.java index 795ee7a1627..735cb650949 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AbstractLdapTest.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AbstractLdapTest.java @@ -482,7 +482,7 @@ protected void assertCapability(List capabili protected ObjectFilter createAttributeFilter(String attrName, T attrVal) throws SchemaException { - ResourceAttributeDefinition ldapAttrDef = accountObjectClassDefinition.findAttributeDefinition(attrName); + ResourceAttributeDefinition ldapAttrDef = accountObjectClassDefinition.findAttributeDefinition(attrName); return QueryBuilder.queryFor(ShadowType.class, prismContext) .itemWithDef(ldapAttrDef, ShadowType.F_ATTRIBUTES, ldapAttrDef.getName()).eq(attrVal) .buildFilter(); diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AdUtils.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AdUtils.java index d638a9e17d5..15c4aad737c 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AdUtils.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/AdUtils.java @@ -30,6 +30,7 @@ import com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition; import com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition; import com.evolveum.midpoint.schema.processor.ResourceSchema; +import com.evolveum.midpoint.test.IntegrationTestTools; import com.evolveum.midpoint.util.DOMUtil; import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType; @@ -45,6 +46,10 @@ public class AdUtils { public static final String ATTRIBUTE_USER_ACCOUNT_CONTROL_NAME = "userAccountControl"; public static final QName ATTRIBUTE_USER_ACCOUNT_CONTROL_QNAME = new QName(MidPointConstants.NS_RI, ATTRIBUTE_USER_ACCOUNT_CONTROL_NAME); public static final String ATTRIBUTE_UNICODE_PWD_NAME = "unicodePwd"; + public static final String ATTRIBUTE_MS_EXCH_HIDE_FROM_ADDRESS_LISTS_NAME = "msExchHideFromAddressLists"; + public static final QName ATTRIBUTE_MS_EXCH_HIDE_FROM_ADDRESS_LISTS_QNAME = new QName(MidPointConstants.NS_RI, ATTRIBUTE_MS_EXCH_HIDE_FROM_ADDRESS_LISTS_NAME); + + public static final QName OBJECT_CLASS_MS_EXCH_BASE_CLASS_QNAME = new QName(MidPointConstants.NS_RI, "msExchBaseClass"); /** * Returns dashed GUID notation formatted from simple hex-encoded binary. @@ -85,7 +90,7 @@ public static ObjectClassComplexTypeDefinition assertAdSchema(PrismObject cnDef = accountObjectClassDefinition.findAttributeDefinition("cn"); - PrismAsserts.assertDefinition(cnDef, new QName(MidPointConstants.NS_RI, "cn"), DOMUtil.XSD_STRING, 1, 1); + PrismAsserts.assertDefinition(cnDef, new QName(MidPointConstants.NS_RI, "cn"), DOMUtil.XSD_STRING, 0, 1); assertTrue("cn read", cnDef.canRead()); assertTrue("cn modify", cnDef.canModify()); assertTrue("cn add", cnDef.canAdd()); @@ -96,7 +101,6 @@ public static ObjectClassComplexTypeDefinition assertAdSchema(PrismObject oDef = accountObjectClassDefinition.findAttributeDefinition("o"); PrismAsserts.assertDefinition(oDef, new QName(MidPointConstants.NS_RI, "o"), DOMUtil.XSD_STRING, 0, -1); @@ -134,4 +138,21 @@ public static ObjectClassComplexTypeDefinition assertAdSchema(PrismObject resource, PrismContext prismContext) throws SchemaException { + + ResourceSchema resourceSchema = RefinedResourceSchema.getResourceSchema(resource, prismContext); + + ObjectClassComplexTypeDefinition msExchBaseClassObjectClassDefinition = resourceSchema.findObjectClassDefinition(OBJECT_CLASS_MS_EXCH_BASE_CLASS_QNAME); + assertNotNull("No definition for object class "+OBJECT_CLASS_MS_EXCH_BASE_CLASS_QNAME, msExchBaseClassObjectClassDefinition); + display("Object class "+OBJECT_CLASS_MS_EXCH_BASE_CLASS_QNAME+" def", msExchBaseClassObjectClassDefinition); + + ResourceAttributeDefinition msExchHideFromAddressListsDef = msExchBaseClassObjectClassDefinition.findAttributeDefinition(ATTRIBUTE_MS_EXCH_HIDE_FROM_ADDRESS_LISTS_NAME); + PrismAsserts.assertDefinition(msExchHideFromAddressListsDef, new QName(MidPointConstants.NS_RI, ATTRIBUTE_MS_EXCH_HIDE_FROM_ADDRESS_LISTS_NAME), DOMUtil.XSD_BOOLEAN, 0, 1); + assertTrue("msExchHideFromAddressLists read", msExchHideFromAddressListsDef.canRead()); + assertTrue("msExchHideFromAddressLists modify", msExchHideFromAddressListsDef.canModify()); + assertTrue("msExchHideFromAddressLists add", msExchHideFromAddressListsDef.canAdd()); + + } + } diff --git a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestAdLdapChimera.java b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestAdLdapChimera.java index 31be909993c..22b332af3e6 100644 --- a/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestAdLdapChimera.java +++ b/testing/conntest/src/test/java/com/evolveum/midpoint/testing/conntest/TestAdLdapChimera.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2015-2016 Evolveum + * Copyright (c) 2015-2017 Evolveum * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,13 +17,12 @@ import java.io.File; -import org.testng.annotations.AfterClass; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.test.annotation.DirtiesContext.ClassMode; +import org.springframework.test.context.ContextConfiguration; import org.testng.annotations.Listeners; import com.evolveum.midpoint.prism.PrismObject; -import com.evolveum.midpoint.test.util.MidPointTestConstants; -import com.evolveum.midpoint.util.exception.ObjectNotFoundException; -import com.evolveum.midpoint.util.exception.SchemaException; import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType; import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType; @@ -31,6 +30,9 @@ * @author semancik * */ +@ContextConfiguration(locations = {"classpath:ctx-conntest-test-main.xml"}) +@Listeners({ com.evolveum.midpoint.tools.testng.AlphabeticalMethodInterceptor.class }) +@DirtiesContext(classMode = ClassMode.AFTER_CLASS) public class TestAdLdapChimera extends AbstractAdLdapMultidomainTest { @Override diff --git a/testing/conntest/src/test/resources/ad-ldap-multidomain/resource-chimera.xml b/testing/conntest/src/test/resources/ad-ldap-multidomain/resource-chimera.xml index 4e310109499..4f27b76f4e7 100644 --- a/testing/conntest/src/test/resources/ad-ldap-multidomain/resource-chimera.xml +++ b/testing/conntest/src/test/resources/ad-ldap-multidomain/resource-chimera.xml @@ -67,7 +67,8 @@ ri:group ri:organizationalUnit ri:domain - + ri:msExchBaseClass + diff --git a/testing/conntest/src/test/resources/common/system-configuration.xml b/testing/conntest/src/test/resources/common/system-configuration.xml index b44049f52f1..629055e2e76 100644 --- a/testing/conntest/src/test/resources/common/system-configuration.xml +++ b/testing/conntest/src/test/resources/common/system-configuration.xml @@ -64,8 +64,8 @@ com.evolveum.polygon.connector.ldap - DEBUG - com.evolveum.polygon.connector.ldap.schema.SchemaTranslator + TRACE + com.evolveum.polygon.connector.ldap.schema DEBUG diff --git a/testing/conntest/src/test/resources/logback-test.xml b/testing/conntest/src/test/resources/logback-test.xml index 1d622355d87..8fb21aab8fe 100644 --- a/testing/conntest/src/test/resources/logback-test.xml +++ b/testing/conntest/src/test/resources/logback-test.xml @@ -17,9 +17,7 @@ - - + ./target/test.log @@ -53,6 +51,9 @@ --> + + + diff --git a/testing/consistency-mechanism/src/test/java/com/evolveum/midpoint/testing/consistency/ConsistencyTest.java b/testing/consistency-mechanism/src/test/java/com/evolveum/midpoint/testing/consistency/ConsistencyTest.java index bd07caca3d8..1cba2fb3b93 100644 --- a/testing/consistency-mechanism/src/test/java/com/evolveum/midpoint/testing/consistency/ConsistencyTest.java +++ b/testing/consistency-mechanism/src/test/java/com/evolveum/midpoint/testing/consistency/ConsistencyTest.java @@ -40,6 +40,7 @@ import javax.xml.namespace.QName; import javax.xml.ws.Holder; +import com.evolveum.midpoint.common.refinery.RefinedResourceSchema; import com.evolveum.midpoint.common.refinery.RefinedResourceSchemaImpl; import org.apache.commons.lang.StringUtils; import org.opends.server.types.Entry; @@ -361,7 +362,7 @@ public static void stopResources() throws Exception { @Test public void test000Integrity() throws Exception { final String TEST_NAME = "test000Integrity"; - TestUtil.displayTestTile(this, TEST_NAME); + displayTestTile(TEST_NAME); assertNotNull(modelWeb); assertNotNull(modelService); assertNotNull(repositoryService); @@ -1190,7 +1191,7 @@ public void test230GetAccountCommunicationProblem() throws Exception { @Test public void test240AddObjectCommunicationProblemAlreadyExists() throws Exception{ final String TEST_NAME = "test240AddObjectCommunicationProblemAlreadyExists"; - TestUtil.displayTestTile(this, TEST_NAME); + displayTestTile(TEST_NAME); // GIVEN openDJController.assumeRunning(); @@ -1228,7 +1229,7 @@ public void test240AddObjectCommunicationProblemAlreadyExists() throws Exception @Test public void test250ModifyObjectTwoTimesCommunicationProblem() throws Exception { final String TEST_NAME = "test250ModifyObjectTwoTimesCommunicationProblem"; - TestUtil.displayTestTile(this, TEST_NAME); + displayTestTile(TEST_NAME); // GIVEN openDJController.assumeStopped(); @@ -1749,7 +1750,7 @@ public void test400GetDiscoveryAddCommunicationProblemAlreadyExists() throws Exc @Test public void test500AddUserMorganWithAssignment() throws Exception { final String TEST_NAME = "test500AddUserMorganWithAssignment"; - TestUtil.displayTestTile(this, TEST_NAME); + displayTestTile(TEST_NAME); // GIVEN openDJController.assumeRunning(); @@ -1766,12 +1767,14 @@ public void test500AddUserMorganWithAssignment() throws Exception { Collection> deltas = MiscSchemaUtil.createCollection(userDelta); // WHEN - TestUtil.displayWhen(TEST_NAME); + displayWhen(TEST_NAME); modelService.executeChanges(deltas, null, task, result); // THEN - TestUtil.displayThen(TEST_NAME); + displayThen(TEST_NAME); result.computeStatus(); + display("result", result); + assertSuccess(result); // assertEquals("Expected handled error but got: " + result.getStatus(), OperationResultStatus.HANDLED_ERROR, result.getStatus()); PrismObject userMorgan = modelService.getObject(UserType.class, USER_MORGAN_OID, null, task, result); @@ -1784,14 +1787,15 @@ public void test500AddUserMorganWithAssignment() throws Exception { // Check shadow PrismObject accountShadow = repositoryService.getObject(ShadowType.class, accountOid, null, result); + display("account shadow (repo)", accountShadow); assertShadowRepo(accountShadow, accountOid, "uid=morgan,ou=people,dc=example,dc=com", resourceTypeOpenDjrepo, RESOURCE_OPENDJ_ACCOUNT_OBJECTCLASS); // Check account PrismObject accountModel = modelService.getObject(ShadowType.class, accountOid, null, task, result); + display("account shadow (model)", accountModel); assertShadowModel(accountModel, accountOid, "uid=morgan,ou=people,dc=example,dc=com", resourceTypeOpenDjrepo, RESOURCE_OPENDJ_ACCOUNT_OBJECTCLASS); - - // TODO: check OpenDJ Account } + /** * Adding a user (morgan) that has an OpenDJ assignment. But the equivalent account already exists on @@ -1800,7 +1804,7 @@ public void test500AddUserMorganWithAssignment() throws Exception { @Test public void test501AddUserChuckWithAssignment() throws Exception { final String TEST_NAME = "test501AddUserChuckWithAssignment"; - TestUtil.displayTestTile(this, TEST_NAME); + displayTestTile(TEST_NAME); // GIVEN openDJController.assumeRunning(); @@ -1861,7 +1865,7 @@ public void test501AddUserChuckWithAssignment() throws Exception { @Test public void test502AssignAccountToHerman() throws Exception { final String TEST_NAME = "test502AssignAccountToHerman"; - TestUtil.displayTestTile(this, TEST_NAME); + displayTestTile(TEST_NAME); // GIVEN openDJController.assumeRunning(); @@ -1919,7 +1923,7 @@ public void test502AssignAccountToHerman() throws Exception { @Test public void test510UnlinkAndUnassignAccountMorgan() throws Exception { final String TEST_NAME = "test510UnlinkAndUnassignAccountMorgan"; - TestUtil.displayTestTile(this, TEST_NAME); + displayTestTile(TEST_NAME); // GIVEN openDJController.assumeRunning(); @@ -1989,7 +1993,7 @@ public void test510UnlinkAndUnassignAccountMorgan() throws Exception { @Test public void test511AssignAccountMorgan() throws Exception { final String TEST_NAME = "test511AssignAccountMorgan"; - TestUtil.displayTestTile(this, TEST_NAME); + displayTestTile(TEST_NAME); // GIVEN openDJController.assumeRunning(); @@ -2131,7 +2135,7 @@ public void test601GetDiscoveryModifyCommunicationProblemDirectAccount() throws @Test public void test800Reconciliation() throws Exception { final String TEST_NAME = "test800Reconciliation"; - TestUtil.displayTestTile(this, TEST_NAME); + displayTestTile(TEST_NAME); openDJController.assumeRunning(); @@ -2207,7 +2211,7 @@ public void test800Reconciliation() throws Exception { @Test public void test801TestReconciliationRename() throws Exception { final String TEST_NAME = "test801TestReconciliationRename"; - TestUtil.displayTestTile(this, TEST_NAME); + displayTestTile(TEST_NAME); openDJController.assumeRunning(); Task task = createTask(TEST_NAME);